我在谷歌地图工作并成功实现了谷歌地图的信息框插件。现在我担心的是我们如何知道标记的信息框是否处于打开状态。这样我就可以在单击标记时切换它...
var locations = [
//this is array of arrays
];
var map = new google.maps.Map(document.getElementById('map_canvas'),{
disableDefaultUI : true,
zoom : 12,
center : new google.maps.LatLng(defaultLatitude,defaultLongitude),
mapTypeId : google.maps.MapTypeId.ROADMAP
});
var mapcode,myOptions;
for (var i = 0,len = locations.length; i < len; i++) {
var marker = add_marker(locations[i][1],locations[i][2],locations[i][3],'this is title',locations[i][0]);
allMarkers.push(marker);
marker.setMap(map);
};
function add_marker(lat,lng,icn,title,box_html) {
var marker = new google.maps.Marker({
animation : google.maps.Animation.DROP,
position : new google.maps.LatLng(lat,lng),
map : map,
icon : icn
});
mapcode = '<this is the code of infobox to show>';
myOptions = {
//options of the infobox...bla bla
};
var ib = new InfoBox(myOptions);
google.maps.event.addListener(marker, 'click', function() {
ib.open(map, marker);
});
return marker;
}
我是谷歌地图的新手,所以可能我错过了一些非常小的东西......提前谢谢...... Ankur