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:[kml_flashembed movie="http://www.cartogrammar.com/flash/panZoomTest.swf" width="210" height="250" /]
And a zoom box example:[kml_flashembed movie="http://www.cartogrammar.com/flash/zoomBoxTest.swf" width="210" height="250" /]