Michael Schultz asks:
Can I update a DataGrid based on data captured from within a Map’s InfoWindow?
The answer is yes and it’s surprisingly easy. Click the image to view the example. The source can be viewed by right clicking the flex application.

To accomplish this, you’ll have to think about what you need to make this happen:
- An ArrayCollection that will be the DataGrid’s dataProvider
- A custom component that will be used as the InfoWindow’s content
- A value object that will represent each person
When you click on the map to add a marker, the following objects are created:
//marker object
var marker:Marker = new Marker(e.latLng);
//value object that represents the person
var personInfo:PersonVO = new PersonVO();
//custom view component for the marker's info window
var nameInput:NameInput = new NameInput();
You then have to pass the personInfo object to nameInput, which is the custom component for the marker’s info window:
//pass a reference of the person object to the info window's custom component
nameInput.setPersonInfo(personInfo);
Then:
//append data to the array collection
acMarkers.addItem({label: label, marker: marker, personInfo:personInfo});
//add event listenter for when the marker is clicked
marker.addEventListener(MapMouseEvent.CLICK, function(e:Event):void {
//open info widow
marker.openInfoWindow(new InfoWindowOptions({customContent:nameInput, width:300, drawDefaultFrame:true}));
});
//add maker overlay to the map
map.addOverlay(marker);
When you update a name in the marker’s info window, it appears in the data grid. How does this happen?
When you set the data grid’s dataProvider attribute, you’re simply passing a reference to an already existing array collection. When the array collection is updated, the change is reflected in the data grid, but only because our array collection is bindable.
Each time a marker is created, a value object called personInfo is created from a bindable class called PersonVO. This object is then added to: 1) the array collection that populates the data grid and 2) the component (nameInput) that makes up the content of marker’s info window. Neither the array collection nor the component actually hold instances of personInfo; what they do is reference it - they only contain pointers to its location in memory. Since it’s bindable, when changes occur to this object, those changes are reflected everywhere it’s referenced. Thus, when you update a person’s name from the info window, the change occurs in the data grid because it references the same location in memory.