My WPF application uses the Flash API for google map. Everything works fine except that I need to show some custom details when the user clicks the balloons.
The actionscript code is below:
var map:Map = new Map();
map.key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
map.sensor = "true";
var marker : Marker;
map.setSize(new Point(stage.stageWidth, stage.stageHeight));
map.addEventListener(MapEvent.MAP_READY, onMapReady);
this.addChild(map);
var CustN:String;
function onMapReady(event:Event):void
{
var centerLL : LatLng = new LatLng(38.05,-77.036562);
map.setCenter( centerLL, 10, MapType.NORMAL_MAP_TYPE);
map.addControl(new ZoomControl());
map.addControl(new PositionControl());
map.addControl(new MapTypeControl());
marker = new Marker( centerLL );
map.addOverlay( marker );
ExternalInterface.addCallback("Search",onSearch);
}
function onSearch(lat:Number, lon:Number, CustName:String ):void
{
CustN = CustName;
var centerLL : LatLng = new LatLng(lat,lon);
map.setCenter(centerLL, 10, MapType.NORMAL_MAP_TYPE);
marker = new Marker( centerLL );
marker.addEventListener(MapMouseEvent.CLICK, onMapClick);
map.addOverlay( marker );
}
function onMapClick(event:MapMouseEvent):void
{
map.openInfoWindow(event.latLng, new InfoWindowOptions({title: "Click Event", content: CustN}));
}
I call the onSearch function from my C# code as below:
foreach (var rec in LstCoOrdinates)
{
XElement call = new XElement("invoke", new XAttribute("name", "Search"), new XAttribute("returntype", "xml"), new XElement("arguments", new XElement("number", rec.latitude)),
new XElement("arguments", new XElement("number", rec.longitude)), new XElement("arguments", new XElement("string", rec.name)));
axFlash.CallFunction(call.ToString(SaveOptions.DisableFormatting));
}
I need to display the name corresponding to the balloon clicked
you can specify DisplayObject .icon property in your g Marker. and change it’s visibility on click.
Predefine label or set it on click whatever you need.