Thoughts and adventures in maps, Flash, visualization, and anything in between

Simple map panning and zooming with ActionScript

A while ago I wrote a summary of basic map panning and zooming methods along with demonstrations of most of them. There were a few requests for code examples for those demos, so (finally) I thought I’d outline some of the simple methods for doing it in Flash/ActionScript.

I’ve put together two AS files:

  • A PanZoomMap class, with some simple panning and zooming methods.
  • An example class that creates an instance of the PanZoomMap and demonstrates zooming, basic click and drag panning, and a zoom box.

The code has some simple comments that I hope give an idea of how it works. I’ll let them do the talking, as anything I write here is likely to be long-winded and confusing.

The example is really very basic. A real interactive map is likely to require some more complicated capabilities than what I have provided here, but this is a starting point that may be helpful to anyone who needs an introduction.

Here’s what the test file does. A simple click-and-drag pan/zoom example:

And a zoom box example:

Tagged ,

3 Comments

  1. Andy

    Have a look at what we have done - I would like your feedback

    Thanks

    Jorgen

    Jorgen
    16 December 2008 @ 1:57pm

  2. [...] my personal site I have posted a very basic tutorial and example of ActionScript code for a simple version of the way I typically code panning and zooming.  If you’re looking for [...]

    Panning and zooming tutorial | Axis Maps Blog
    16 December 2008 @ 8:14pm

  3. Hello, I’ve been testing the possibilities offered by Silverlight, especially the MultiScaleImage object, and thought the “pyramidal” method they use to benefit from different resolutions of the same image, cut down in tiles of constant weight, was quite smart, and could be ported to actionscript…
    have a look at the site they showed at MIX : http://memorabilia.hardrock.com/
    I’d say the result is quite impressive, and really match your work.

    shiva
    22 December 2008 @ 11:37am

Leave a Comment