开发者

Flex Flashbuilder Google Maps

Hi I'm wondering if anybody could help me with a problem I'm trying to solve with Flex & google maps.

I have a map that is populated by markers. Each marker has an event listener. And what I am hoping to achieve is that when each marker is clicked that a datagrid is populated with the data associated to that marker. However at the moment I can only populate the data grid with the LatLng object. I need to find a way to access the other data associated with that Marker.

Here is my event listener:

private function createMarker(latlng:LatLng, int:Number, tip:String, desc:String):Marker
{
    var m:Marker = new Marker (latlng, new MarkerOptions ({hasShadow: true, tooltip: "" +tip}));
    m.addEventListener(MapMouseEvent.CLICK, function(event:MapMouseEvent):void
        {details.addItem(event.latLng.toString());});
    return m;
}

I was thinking it might be along the lines of getitem where LatLng = event.latLng but开发者_StackOverflow I'm really new to flex so I can't figure it out at all.

Any ideas that might put me on the right track would be really appreciated.

L


Try this:

private var markerArray:Array = [];
private var markerDescriptsArray:Array = [];
private function createMarker(latlng:LatLng, int:Number, tip:String, desc:String):Marker
{
    var m:Marker = new Marker (latlng, new MarkerOptions ({hasShadow: true, tooltip: "" +tip}));
    m.addEventListener(MapMouseEvent.CLICK, function(event:MapMouseEvent):void
    {
         var _mIndex:uint;
         for (var i:uint = 0; i < markerArray.length; i++)
         {
             if(markerArray[i] == Marker(e.currentTarget)) _mIndex = i;
         }
         details.addItem(markerDescriptsArray[_mIndex]);
    });
    markerArray.push(m);
    markerDescriptsArray.push(desc);
    return m;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜