marker and zIndex

139 views
Skip to first unread message

rlk27

unread,
Nov 8, 2011, 9:36:06 AM11/8/11
to google-map...@googlegroups.com
I create multiple markers with label overlay on the top.  I set each marker with ZIndex value 700 and label with marker's zIndex+1.  it works fine.  I do have mouseover, out, click event handlers.
 
THe markers are redrawn (deleted and created again) based on the latlag change (moves).  when 2 or 3 makers are overlapping and, I see that the bottom marker when moves, and redrawn, it comes on the top. this is because I always use 700 for marker and +1 for label overlay. I also see the it comes on the top.. btu I can not see it until refresh. 
 
when I have click the top marker in the overlapping scene for a infowindow, the bottom marker moves (redrawn) comes on the top (but not visible until refresh) mouse is still on the position and creates mouseover event on the one redrawn. because it is not visible until refresh, it is confusing to see.
 
I want the bottom marker in the overlapping situtation to maintain it s zIndex and not come in the front.  Any suggestions.  marker creation is the same function which uses the 700 alway. any way to find zindex from the laglat?
 
Thanks
rlk27

geoco...@gmail.com

unread,
Nov 8, 2011, 9:42:27 AM11/8/11
to Google Maps JavaScript API v3
You could set the zIndex based on the coordinates.

-- Larry

>
> Thanks
> rlk27

rlk27

unread,
Nov 8, 2011, 10:06:19 AM11/8/11
to google-map...@googlegroups.com
Is there any calculation to get the zIndex based on the coordinates?  Any example or link would be appreciated.

geoco...@gmail.com

unread,
Nov 8, 2011, 12:30:26 PM11/8/11
to Google Maps JavaScript API v3
On Nov 8, 7:06 am, rlk27 <ramapragat...@gmail.com> wrote:
> Is there any calculation to get the zIndex based on the coordinates?  Any
> example or link would be appreciated.

I do it in most of my maps. See these examples ported to v3 from Mike
Williams' v2 tutorial:

http://www.geocodezip.com/v3_MW_example_map1.html
http://www.geocodezip.com/v3_MW_example_map2.html

They do this:
zIndex: Math.round(latlng.lat()*-100000)<<5

-- Larry

rlk27

unread,
Nov 8, 2011, 2:19:26 PM11/8/11
to google-map...@googlegroups.com
I tired this already but did not work in my case thsi gives negative number.   As I have many types of markers with each one with their zindex. (100,200,300, 700) so, I used positive 100000.
 

Math.round(marker.getPosition().lat()*100000)<<5  for the marker and marker.getZIndex() + 1 for label overlay.

 

the problem now is that when 2 or more markers are overlapping, when I click on the bottom one, it is redrawn. but it is not coming up.  I want the makers to comeon the top when clicked.  I dont think we have change zIndex. so, I remove and create new marker, zIndex is above calculation. does not come on the top.

 
Reply all
Reply to author
Forward
0 new messages