I have a problem with Google Maps API v3. I'm trying to remove a mouseover listener when zoom changes.
Here is my code:
$(document).ready(function() {
var myOptions = {
...
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
function colormaps(map) {
var newmap = map;
var piemonteCoords = [
...
];
var piemontePolygon = new google.maps.Polygon({
...
});
piemontePolygon.setMap(newmap);
google.maps.event.addListener(piemontePolygon, 'mouseover', function(event) {
var prova = event;
showInfo(prova, newmap, 'Italy');
});
google.maps.event.addListener(newmap, 'zoom_changed', function() {
zoomLevel = map.getZoom();
if (zoomLevel >= 6) {
google.maps.event.clearListeners(newmap, 'mouseover');
}
else {
...
}
} //fine colormaps
google.maps.event.addDomListener(window, 'load', colormaps(map));
});
When zoom reaches the target level, the listener is not removed. What's wrong?