I've been investigating this for a while now and I'd be most
interested to hear if you find a practical solution.
I'm adding mountains to the map as markers via a database with their
heights, latlng's and various other information. I tried adding them
as a loop (shown below).
public function populateMap():void{
map.clearOverlays();
for each(var o:Object in munrosArray){
var markerOptions:MarkerOptions = new MarkerOptions();
markerOptions.icon = new GlobalVariables.munroIcon();
markerOptions.iconAlignment =
MarkerOptions.ALIGN_HORIZONTAL_CENTER;
markerOptions.iconAlignment =
MarkerOptions.ALIGN_VERTICAL_CENTER;
markerOptions.tooltip = o.Name;
var latlng:LatLng = new LatLng(o.Latitude,o.Longitude);
var marker:Marker = new Marker(latlng,markerOptions);
var details:InfoWindowOptions = new InfoWindowOptions({
customContent: new CustomInfoWindow(o.Name, o.Metres,
o.Feet,
o.Latitude, o.Longitude, o.GridRef, o.ColGridRef),
customOffset: new Point(50, 50)});
marker.addEventListener(MapMouseEvent.CLICK,
function(event:Event):void{marker.openInfoWindow(details);});
map.addOverlay(marker);
}
}
It works perfectly for the tooltip, but not for the CustomInfoWindow,
always showing the last added mountain's information. I realise this
is because it doesn't store the data in the infoWindow, but I'd really
like a way to fix this.
On Oct 31, 7:01 am, TheDarkIn1978 <[email protected]> wrote:
> it seems the (only?) way to pass custom data to a markers MapMouseEvent
> listener is to to use a function closure. personally, i find function
> closures to be kinda ghetto because they are not easily referenced and
> make the code look ugly.
>
> is there a way, perhaps, to add custom data to the Marker object or
> even the markerOptions object? being able to set custom data object as
> a property of a Marker would be more elegant, in my opinion. something
> like the following:
>
> var myCustomData:Object = new Object();
> myCustomData.label = "My Marker Label";
> myCustomData.index = 1;
>
> var marker:Marker = new Marker(new LatLng(45.53329,-73.67638));
> marker.data = myCustomData;
> marker.addEventListener(MapMouseEvent.CLICK, mapMouseEventHandler);
>
> private function mapMouseEventHandler(evt:MapMouseEvent):void
> {
> var target:Marker = evt.currentTarget;
> trace("Number " + target.data.index + ": " + target.data.label);
>
>
>
> }
--
You received this message because you are subscribed to the Google Groups
"Google Maps API For Flash" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api-for-flash?hl=en.