Getting things on a map

Custom marker in Google maps for Flash
Custom marker in Google maps for Flash

Yesterday I continued with my Flash web app. I’d already done some tests with part of the application. For example displaying a map inside Flash. Only recently Google maps have released an API for working with Google maps inside Flash. This makes it very easy to include (interactive) maps inside your Flash app. Of course when you want different things it’s harder 🙂

I want to display two maps, one for Amsterdam and one for Breda. On the map you can follow me around for two weeks. I wanted to use a fitting icon to display where I have been. So I designed a heart to indicate where it was beating at a certain time. I thought it would be simple to display my custom marker. But I could only find difficult and not so logical examples explaining how this is done. So with a fresh mind in the morning I took a new look at the documentation and worked it out. As it took me quite some time to work this simple code out I’ll just repeat it here for those interested:

function onMapaReady(event:Event):void {
   map_a.setCenter(new LatLng(b_line_array[2],b_line_array[3]), 14, MapType.NORMAL_MAP_TYPE);
   var a_icon:Marker = new Marker(   new LatLng(b_line_array[2],b_line_array[3]),
   new MarkerOptions({
      icon: new my_icon()
   })
);
map_a.addOverlay(a_icon);
}

So in my library I have a movie clip called (linkage) my_icon. I use this for the Amsterdam and the Breda map, except that it’s called b_icon there, the rest of the code is the same. Make sure you import the marker classes:

import com.google.maps.overlays.Marker;
import com.google.maps.overlays.MarkerOptions;

And add the overlay, then you’re done.

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.