I use a method that adds the marker and infowindow options to the data
array.
This is not working code just a guide, hope it helps.

  Create a custom MarkerInfoWindow mxml component that has a var
Data:Object
  and code that on creation sets the fields within the window to
elements of the Object
  i.e fldLastName.text = Data.lastName;

  When creating the marker create the InfoWindowOptions

  var newDataWindow:DataTabWindow = new DataTabWindow();
  //Set the public variable in your infoWinfow class
  newDataWindow.Data = myDataArray[index];

  var IWOptions:InfoWindowOptions = new InfoWindowOptions({
    customContent: newDataWindow,
    customOffset: new Point(0, 10),
    width: 280,
    height: 280,
    drawDefaultFrame: true
    });

  // Add marker and infoWindowOptions to your data array
  myDataArray[index]["Marker"] = sMarker;
  myDataArray[index]["IWOptions"] = IWOptions;

  // Add click event listener to launch infoWindow
  myDataArray[index].Marker.addEventListener(MapMouseEvent.CLICK,
        function (event:MapMouseEvent):void {
          var tIndex:int = findIndexFromMarker(event.target as Marker);
 
myDataArray[tIndex].Marker.openInfoWindow(myDataArray[tIndex].IWOptions);
        });

  map.addOverlay(myDataArray[index].Marker);

  // function to find index from marker in data array
  private function findIndexFromMarker(m:Marker):int {
   var nCount:Number = myDataArray.length;
   var i:int;
   for (i = 0; i < nCount ; i++) {
     if (myDataArray[i].Marker == m) {
       break;
     }
   }
   return i;
  }


On Nov 1, 5:01 am, TheDarkIn1978 <[email protected]> wrote:
> thanks Carol. that's a smart choice to avoid using function closures
> and it's inherent difficulties for removal. however, it not really that
> much more of an elegant solution since it's a bit hacky, plus i'm a
> little allergic to using MovieClips over Sprites, but it would be
> certainly easier to manage and beggars can't be choosers!
>
> here's hoping that Google supplies a better solution to handle custom
> data in future updates of the API
>
> since my post i've learned (the very ugly way) how to remove event
> listeners added via function closures. here's my code (custom data is
> supplied from an XML file):
>
> private function mapReadyEventHandler(evt:MapEvent):void
> {
> //Remove Event Listener
> evt.currentTarget.removeEventListener(MapEvent.MAP_READY,
> mapReadyEventHandler);
>
> // // // MAP STYLE CODE // // //
>
> //Assign Marker For Each XML Station Element
> for each (var station:XML in XMLData..station)
> {
> //Assign Marker Options
> var markerOptions:MarkerOptions = new MarkerOptions();
> markerOptions.icon = new StationMarkerIcon();
> markerOptions.hasShadow = false;
>
> //Add Created Marker To Map Overlay
> map.addOverlay(createMarker(station.lat, station.long, markerOptions,
> station.name, station.cars));
>
> }
> }
>
> //Create Marker
> private function createMarker(latitude:Number, longitude:Number,
> markerOptions:MarkerOptions, stationName:String,
> availableCars:uint):Marker
> {
> var functionClosure:Function;
> var resultMarker:Marker = new Marker(new LatLng(latitude, longitude),
> markerOptions);
>
> //Assign Mouse Event Listener To Marker
> resultMarker.addEventListener(MapMouseEvent.CLICK,
> function(evt:MapMouseEvent):void
> {
> //Reference Function For Event Listener Removal:
> removeEventListener(MapMouseEvent.CLICK, functionClosure)
> functionClosure = arguments.callee;
>
> //Event
> trace(latitude, longitude, stationName, availableCars)
>
> });
>
> return resultMarker;
>
>
>
> }- Hide quoted text -
>
> - Show quoted text -

-- 
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.

Reply via email to