That's correct, it's necessary to achieve something called "function closure" on the marker variables. There's more detail in the developer's guide: http://code.google.com/apis/maps/documentation/flash/events.html#Event_Closures
- pamela On Mon, Jan 19, 2009 at 6:51 PM, Jeremy Rottman <[email protected]> wrote: > > I got this figured out. > > Here is what I did. > > public function addMarker(markArr:Array):void{ > var markerOpt:MarkerOptions = new MarkerOptions({strokeStyle: > new > StrokeStyle({color: 0x987654}), > fillStyle: new FillStyle({color: 0x223344, alpha: > 0.8}), > radius: 12, > hasShadow: true}); > for(var i:Number=0; i < markArr.length; i++){ > var gisData:LatLng = new > LatLng(markArr[i].gis_lat,markArr > [i].gis_long); > var marker:Marker = createMarker(gisData, > markArr[i].mName); > marker.setOptions(markerOpt); > this.addOverlay(marker); > } > } > > private function createMarker(gisData:LatLng, > markerData:String):Marker{ > var marker:Marker = new Marker(gisData); > marker.addEventListener(MapMouseEvent.CLICK, function > (event:MapMouseEvent):void { > marker.openInfoWindow(new InfoWindowOptions({content: > markerData})); > }); > > return marker; > } > > On Jan 18, 5:12 pm, Jeremy Rottman <[email protected]> wrote: >> I am working on an application that plots marker points for multiple >> locations. Each location should have an infobox open up when the user >> clicks on the marker. However, no matter what I try, I can no get the >> infowidow to open when a user clicks on the marker. Any help with this >> would be greatly appreciated. >> >> If correctly adds a marker for each point I want to plot. >> >> Here is my current code base. >> >> public function addMarker(markArr:Array):void{ >> var markerOpt:MarkerOptions = new >> MarkerOptions({strokeStyle: new >> StrokeStyle({color: 0x987654}), >> fillStyle: new FillStyle({color: 0x223344, alpha: >> 0.8}), >> radius: 12, >> hasShadow: true}); >> >> for(var i:Number=0; i < markArr.length; i++){ >> var gisData:LatLng = new >> LatLng(markArr[i].gis_lat,markArr >> [i].gis_long); >> var marker:Marker = new Marker(gisData,markerOpt); >> marker.addEventListener(MapMouseEvent.CLICK, function >> (event:MapMouseEvent):void { >> marker.openInfoWindow(new >> InfoWindowOptions({content: markArr >> [i].mName})); >> }); >> this.addOverlay(marker); >> } >> } > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
