Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Max initial zIndex for Google Maps V3 markers

I'm building a google maps web site with markers placed onto the map. Some times the markers overlap so I want to be able to interactively bring to the front specific markers.

I can use setZIndex() for this. But I need to know the initial max zindex of all the markers. getZIndex() is no use as it doesnt seem to return anything unless youve already called setZIndex().

It would be tempting to say "just start with a very big number" but I believe Google uses latitude or something to calculate the initial zIndex so the maximum zindex may vary? Making this scheme risky.

Does anyone know what the max initial zIndex will be for N markers in Google Maps V3?

like image 868
spiderplant0 Avatar asked Oct 28 '11 17:10

spiderplant0


1 Answers

You can use the constant MAX_ZINDEX to ensure that the marker will display on top.

marker.setZIndex(google.maps.Marker.MAX_ZINDEX + 1);

Search the reference of the constant in the Google Maps API V3 Documentation

like image 139
Alejandro Fiore Avatar answered Oct 13 '22 07:10

Alejandro Fiore