hello all, I'm new to flex and google maps..and trying to create an
application which store places data into the database. I'm using
AMFPHP services to manipulate the data..
I have succeeded populating marker trough the data I've stored and now
I'm planning to make like this: when user click the marker, it's popup
a tile window component which contain the detail (or more data) of the
clicked marker/place...
I'm also using info window to show less data inside info window
tooltip when user rollover the marker..and it's works fine...
The tile window component popup correctly but the problem is the data of
clicked marker show the same data in any marker...this is my code :
// to retrieve data from amfphp result //
private function getResultHandler(re:ResultEvent):void{
var res:Array = re.result as Array;
resultData= new ArrayCollection(res);
}
// populate marker to map //
public function addMarker(event:Event):void{
var markersCount:int = resultData.length;
var i:Number;
for (i=0; i < markersCount; i++) {
var name:String = resultData[i]['name'];
var address:String = resultData[i]['address'];
var type:String = resultData[i]['type'];
var latlng:LatLng = new LatLng(resultData[i]['lat'],
resultData[i]
['long']);
var marker:Marker = createMarker(latlng, name, address,
type);
infoWin.myarray.addItemAt({name:resultData[i]['name'],
address:resultData[i]['address'], type:resultData[i]['type']},i);
map.addOverlay(marker);
}
}
// create marker //
public function createMarker(latlng:LatLng, name:String,
address:String, type:String): Marker {
var marker:Marker = new Marker(latlng, new MarkerOptions
({iconOffset: new Point(-16, -32)}));
var html:String = "<b>" + name + "</b> <br/>Alamat: " + address
+"<br/>Tipe: "+type;
marker.addEventListener(MapMouseEvent.ROLL_OVER,
function(e:MapMouseEvent):void {
marker.openInfoWindow(new InfoWindowOptions
({contentHTML:html}));
});
marker.addEventListener(MapMouseEvent.ROLL_OUT,
function(e:MapMouseEvent):void {
marker.closeInfoWindow();
});
marker.addEventListener(MapMouseEvent.CLICK,showInfo);
return marker;
}
// show tile window component popup //
public function showInfo(event:MapMouseEvent):void {
var infoWin:detailInfoWin = new detailInfoWin();
PopUpManager.addPopUp(infoWin,panel1,false);
PopUpManager.centerPopUp(infoWin);
var i:Number;
}
// and here is my custom component //
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" width="400" height="300" title="Detail"
showCloseButton="true" close="PopUpManager.removePopUp(this)">
<mx:Label x="20" y="10" text="Label"/>
<mx:Label x="75" y="10" id="nametxt" text="{myarray.getItemAt(i)
['name']}"/>
<mx:Label x="20" y="36" text="Label"/>
<mx:Label x="75" y="36" id="addresstxt" text="{myarray.getItemAt(i)
['address']}"/>
<mx:Label x="20" y="62" text="Label"/>
<mx:Label x="75" y="62" id="typetxt" text="{myarray.getItemAt(i)
['type']}"/>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.managers.PopUpManager;
[Bindable]
public var myarray:ArrayCollection = new
ArrayCollection([{name:"",
address:"", type:""}]);
public var i:Number;
]]>
</mx:Script>
</mx:TitleWindow>
so how to display the right data values on each clicked marker?...
(sorry for my bad english..:D)