Google Blogoscoped


Google Maps Z-indexing?

alek [PersonRank 10]

Wednesday, November 15, 2006
13 years ago12,643 views

I've poked around the Google Map documention and general Google searches, but have not found the answer to what should be an easy question – can one set a Z-index for a maker on Google Maps?

As an example, take a look at this (over-the-top) page – – in addition to the 1,000 markers (yea, I know that clutters it up a bit), I have a few "special" markers that I would like to be visible – specifically the "christmas lights house" in the middle of the United States. This ends up getting kinda obscured and I would like it to be "on top" – i.e. like a Z-index.

I've tried switching the load order, but that did not seem to make any difference. And there are a few fleeting references in the Maps API docs, but I didn't see anything solid.

Is it even possible to "force" a marker to be on top of a Google Map?

Thanks in advance for any ideas/suggestions.

alek [PersonRank 10]

13 years ago #

Just as a follow-up, I "gave up" on using that approach – some z-index stuff went away with version 1 of the API and isn't supported in version 2. I ended up doing an info box as a hack work-around ...

alek [PersonRank 10]

13 years ago #

As a follow-follow-up, Google recently added a method to do this – a good read is at: ...
and here is a cut-n-paste from that URL:

From v2.70, it's possible to set the z-index of markers.

You might want to do this if your map tends to be rather cluttered with overlapping markers, and you want to highlight a particular marker, but normally find it to be partially obscured behind less significant ones.

To use the facility, you need to create a little function which will return an integer to be used as the z-index. Markers with higher z-index values are drawn on top of those with lower z-index values.

You can calculate the value from scratch, or you might modify the usual value, which can be obtained from GOverlay.getZIndex(marker.getPoint().lat()).

The function is passed two parameters. The first parameter is a reference to the marker and the second one always seems to be undefined at present.

Attach your function to the marker by using the GMarkerOption {zIndexProcess:myFunction}

You can't change the order of the markers afterwards. The function only gets evaluated when the marker is addOverlay()ed.

So if you hit my Christmas Maps Page now:
In addition to the tabbed popup, you should see a
"house" icon in Colorado and a "tree icon" near where
you are – the later is dependant on geolocation working.

Both of those icons should *now* be on top of the snowflakes;
whereas before, they ended up being covered up.

This thread is locked as it's old... but you can create a new thread in the forum. 

Forum home


Blog  |  Forum     more >> Archive | Feed | Google's blogs | About


This site unofficially covers Google™ and more with some rights reserved. Join our forum!