google.maps.Marker.prototype.hide = function()开发者_如何学Go
{
if (this.div_)
{
this.div_.style.visibility = "hidden";
}
};
google.maps.Marker.prototype.show = function()
{
if (this.div_) {
this.div_.style.visibility = "visible";
}
};
It doesnt cause any error. But it doesnt work while Im using it:
marker = new google.maps.Marker({
map: map,
draggable: false,
position: latlng,
title: 'some title'
});
And now if someone change the zoom I want to trigger hiding marker:
google.maps.event.addListener(map, 'zoom_changed', function() {
marker.hide();
});
But it doesnt work. Could someone help me resolve the problem?
to hide a marker use marker.setMap(null);
to show again use marker.setMap(mymap);
EDIT:
forgot about setvisible. here's a working example: http://jsfiddle.net/herostwist/v9nmQ/1/
The API already contains such a method: setVisible
. Either pass true
or false
.
精彩评论