I am working in google maps and successfully implemented the infobox plugin of google maps.Now my concern is that how can we know that the infobox for a marker is in open state or not. so that I can toggle it on click of the marker…
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;
}
I am new in google maps so may be I am missing some very small stuff…thanks in advance….
Ankur
In case you just need one infobox open at any time you could do it like that:
If you do it like that you need to reset flag every time you call ib.close() with ib.isOpen = false; (you didn’t specify in what situations do you close the box)
In case you need multiple boxes to be opened:
And again if you ever call allMarkers[…].ib.close() you will need to reset the flag with allMarkers[…].ib.isOpen = false;
I hope this helps.