Google Maps AS3 API V1.16 Tips
Sep 20th, 2009 by Leo A. Geis
I’ve been spending quite a bit of time developing a Google Maps Flash application over the past 2 weeks, and I’ve found solutions for what appear to be some common pitfalls.
I found some of these solutions on the Google Maps for Flash API For Flash Group Forum-which I highly recommend if you are involved in with Google Maps Development.
I watched a Captivate video of someone working the API in Flex and noticed that they had full Code Hinting (Code Completion) functionality for .swc Classes, Methods and Properties. I’ll drop a feature request in to Adobe for Flash to interrogate .swc’s or any imported Packages, Classes et. al. to generate Code Hints in the Flash API, but I have a suspicion that Flex and Flash will morph into the same application (probably called “Flesh”) by the time that capability rolls around.
If you Declare a new LatLng Instance and try to use a var as the first Argument, you’ll be frustrated. The Constructor is looking for two Arguments-not one. There are several clever ways to resolve the issue but the simplest (and therefore most elegant) is to Declare the lat and lon vars and pass them individually. If you wish to store them together for whatever reason, declare them as a String and use the String Class’ split() Method to “split” them before passing them (be sure to plan your Delimiter).
If you set up Listeners for both, Polyline Instances and Map Instances will provide you with MouseEvent.CLICK Events. In order to frustrate the Map Event and capture only the Polyline Event, consider that the Event Flow Bubbles down through the Map from the Polyline-simply modify the Polyline’s Event Propogation by assigning the Boolean False to the “Bubbles” Parameter: See the AS3LR flash.events.MouseEvent bubbles Parameter.
Don’t invoke the removeChild() Method for a Map Instance. It appears to me that once a Map Instance is zoomed or panned it acts like a discreet Instance and won’t satisfy the Call. Fortunately for those who actually take the time to read the API Language Reference, the Map Class does offer a unload() Method. It works!
L


