Google Maps API InfoWindow HTML Dynamic Content

I work in Flash Builder 4 with the Google Map ActionScript API. I created a map, loaded some custom markers onto it, and added some MouseEvent listeners to each marker.

The problem occurs when I load the InfoWindow panel. I want to dynamically set htmlContent based on the information stored in the database. The problem is that this information can change every two seconds, and each marker has a unique data set, so I cannot statically set it during marker creation. I have a method that loads all the records from my database into the Object variable every minute. Everything that I need to display in htmlContent is contained in this object under a unique identifier.

The main problem is that for me there is no way to uniquely identify the information window, so I can not determine what information to display in the panel.

marker.addEventListener(MapMouseEvent.ROLL_OVER, function(e:MapMouseEvent):void { showInfoWindow(e.latLng) }, false, 0, false); 

This is my mouse event listener. The function I call, "showInfowindow", looks like this:

 private function showInfoWindow(latlng:LatLng):void { var options:InfoWindowOptions = new InfoWindowOptions({title: appData[*I NEED A UNIQUE ID HERE!!!*].type + " Summary", contentHTML: appData[*I NEED A UNIQUE ID HERE!!!*].info}); this.map.openInfoWindow(latlng, options); } 

I thought that I could do something by passing a variable in the declaration of the event listener, but she just hates passing a dynamic variable, it returns only the last value.

Example:

 marker.addEventListener(MapMouseEvent.ROLL_OVER, function(e:MapMouseEvent):void { showInfoWindow(e.latLng, record.unit_id) }, false, 0, false); 

This decision is painfully close to work. I repeat the loop to create my markers, when I try the above solution and flipped the marker, I get information, but each marker information reflects any information created by the last marker.

I apologize for the long explanation, but I just wanted to make my question as clear as possible. Does anyone have any ideas on how to fix my almost-something solution that I posted below or from the very beginning?

Thanks in advance,

Peter Hanneman

0
flex dynamic actionscript-3 google-maps infowindow
Jun 15 2018-10-15T00:
source share
1 answer

I created a very ugly workaround at the moment.

Since each marker longitude and latitude is unique, I added a bit of code where the markers are added to a map that created a globally visible associative array that used the hash of the Google Map API location object as a key and my unique identifier as a value. Then, when my event listener was launched, I was able to extract the location object from the returned event, the hash file, search my array and pull out a unique identifier to pull out certain marker information in InfoWindow.

It works wonderfully, but it leaves me dirty. Please tell someone has a better solution?

0
Jun 16 '10 at 20:28
source share
— -



All Articles