我正在尝试使用Flex 3创建Google地图,以显示学校的位置。当用户滚过学校标记时,InfoWindow应该显示学校的名称。
标记工作正常。不幸的是,学校的名字没有显示在InfoWndow中。我认为我在InfoWindowOptions中遇到了问题。
请参阅以下功能:
public function schoolMarkerBuilder():void {
var schoolArrayLength:uint = schoolPointsData.length;
var i:int;
for (i=0; i < schoolArrayLength; i++) {
schoolMarkers = new Marker(new LatLng(schoolPointsData[i].latitude, schoolPointsData[i].longitude),
new MarkerOptions({
strokeStyle: new StrokeStyle({color: 0x000000}),
fillStyle: new FillStyle({color: 0x223344, alpha: 0.8}),
radius: 12,
hasShadow: true
})
);
schoolMarkers.addEventListener(MapMouseEvent.ROLL_OVER, function(event:MapMouseEvent): void {
map.openInfoWindow(event.latLng, new InfoWindowOptions({content:schoolPointsData[i].school_name, hasCloseButton:false, hasShadow:true}));
});
map.addOverlay(schoolMarkers);
}
}
有什么建议吗?
谢谢。
-Laxmidi
答案 0 :(得分:1)
好的,我明白了。请参阅以下代码:
public function schoolMarkerBuilder():void {
var schoolArrayLength:uint = schoolPointsData.length;
var i:int;
for (i=0; i < schoolArrayLength; i++) {
var options:InfoWindowOptions = new InfoWindowOptions({content: schoolPointsData[i].school_name});
schoolMarkers = new Marker(new LatLng(schoolPointsData[i].latitude, schoolPointsData[i].longitude),
new MarkerOptions({
strokeStyle: new StrokeStyle({color: 0x000000}),
fillStyle: new FillStyle({color: 0x223344, alpha: 0.8}),
radius: 12,
hasShadow: true
})
);
createMarker(schoolMarkers, options);
}
}
private function createMarker(m:Marker, o:InfoWindowOptions):void {
m.addEventListener(MapMouseEvent.ROLL_OVER, function(e:Event):void {
m.openInfoWindow(o);
});
map.addOverlay(m);
}
谢谢。
-Laxmidi