Hi Idaho,
I think having the addMarker function as an internal function is a bit
weird in the first place.  Here's how I'd organize this, in creation
complete register a listener for the map ready event, then in the map
ready event handler have it call a method to add the markers, if the
problem is the data might come back before or after the maps is ready
go ahead and break the problem apart.

So make it so the map ready handler tries to call a third method that
handles adding the markers, then in the method that handles the
results of the get property lat lng requests also call the third
method, in the third method you do the add marker stuff you're doing
in here but also add checks for if the map ready has fired and if the
location result handler has been fired (just make booleans mark them
true in those methods) so the third method will be called twice every
time your application loads but will only execute adding the markers
on the second call (that is after the map is ready and the property
lat/lngs have been resolved, regardless of the order they happen in
you know you'll still be good to add markers at this point.  Something
weird is probably happening with the listener you're adding in the
loop generally you should be able to just add a listener to an object
once so this would be better outside the loop... you don't want it to
call that function for as many items as... oh okay it makes sense
now... so you are referencing markerXML in there, that probably has
the same value every time that it does the call back to your
handler... yeah I can't think of an easy way to make that really work,
you'd need the event to be able to tell you which marker was added.

So basically in pseudocode this is what I'd do

private var isMapReady:Boolean,isDataLoaded:Boolean;

//Guarantees the map exists so you can listen to events from it
creationComplete()
{
map.addListener("mapReadyEvent",mapIsReady);
httpServiceOrWhatever.addListener("complete",dataIsReady);
fetchData();
}

fetchData()
{
httpServiceOrWhatever.send();
}

mapIsReady()
{
isMapReady=true;
addMarkers();
}

dataIsReady()
{
isDataReady=true;
addMarkers();
}

addMarkers()
{
if(isDataReady&&isMapReady)
    doStuffToAddMarkersBasicallyYourExistingCode();
}

Good luck
Shaun

On Sep 9, 7:33 am, "Idaho Airships, Inc." <[email protected]>
wrote:
> Greetings from Boise!
>
> I'm parsing a successfully URLLoaded .xml file (now an XMLList) with
> the following code:
>
> for(var i:uint = 0; i<propertyList.length(); i++) {
>
>      var address:String = markerXML.Address;
>      var propertyLat:Number = markerXML.GoogleLatitude;
>      var propertyLong:Number = markerXML.GoogleLongitude;
>
> mapA.addEventListener(MapEvent.MAP_READY, addMarker);
>
>      function addMarker(e:MapEvent):void {
>
>           var markerLatLng:LatLng = new
> LatLng(markerXML.GoogleLatitude, markerXML.GoogleLongitude);
>
>           var markerOptions = new MarkerOptions({hasShadow: true,
> tooltip: String(markerXML.Address)});
>
>           var propertyMarker = new Marker(markerLatLng,
> markerOptions);
>
>           mapA.addOverlay(propertyMarker);
>
>      }
>
> }
>
> All of the above is contained in a single Event Handler for the
> successful URLLoader COMPLETE. I'm looping through the .xml of 10
> different properties but again...only the last one posts.
>
> I'm certain that this is just a pre-dawn/working all night brain
> misfire. What's missing, please?
>
> Thanks!
>
> Everything works great(!) except for the fact that a Marker is posted
> only for the last element in the .xml list.

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