Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show google map marker depending on what zoomlevel you're on

I'm wondering if it's possible to set markers to be visible in a chosen zoom level for the
Google Map API v3.
I figured it's possible in the v2 of the API using the "Marker Manager" but can't find a way for the latest API.

Example:
Marker-1 -> (max_zoom:10, min_zoom:5) //will on be shown within zoom level 5-10
Marker-2 -> (max_zoom:15, min_zoom:10) //will on be shown within zoom level 10-15

As I'm developing an jQuery-plugin I only want to use the original API without add-ons.

Thanks in advance!

like image 807
Maartin Avatar asked Jan 23 '26 03:01

Maartin


1 Answers

Supposing map is the object instanced to manage the gmap, i'd do something like this:

var zoomLevel =  map.getZoom();
if (zoomLevel>=5 && zoomLevel<=10) { 
     // call the setMarker function for the marker1
} else if (zoomLevel>10 && zoomLevel<=15) {
     // call the setMarker function for the marker2
}

Maybe u want to handler the zoom change event, if so look at this: http://code.google.com/apis/maps/documentation/javascript/events.html

like image 109
lucke84 Avatar answered Jan 24 '26 21:01

lucke84