Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to create an event listener that turns off a google fusion layer once the map is zoomed in to a certain level. I'm pretty new to javascript and its google maps api, so any help is appreciated. I found some code that seems close to what I need:

google.maps.event.addDomListener(map,'zoom_changed', function() { var zoom = map.getZoom(); if (zoom >=1 && zoom <=9) { layer_0.setMap(map); layer_1.setMap(map);

} else if (zoom >9 && zoom <=11) { layer_0.setMap(map); layer_1.setMap(map);

} else if (zoom >11) { layer_0.setMap(null); layer_1.setMap(map);

} });

Thanks in advance!

share|improve this question
add comment

1 Answer

Here is some code I'm successfully using to toggle a Fusion Tables layer in one of my maps:

google.maps.event.addListener(map, 'zoom_changed', function() {
    zoomLevel = map.getZoom();
    if (zoomLevel >= minFTZoomLevel) {
        FTlayer.setMap(map);
    } else {
        FTlayer.setMap(null);
    }
});

it looks almost identical to your code, apart from addListener vs addDomListener. Can you try adding a breakpoint inside your function to make sure it's actually running?

share|improve this answer
    
Thanks for your help. I'm definitely a novice when in comes to Google Maps and Javascript, so I'm still working on it. –  b-rad-b Aug 20 '13 at 17:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.