jawj / OverlappingMarkerSpiderfier

Deals with overlapping markers in Google Maps JS API v3, Google Earth-style
http://blog.mackerron.com
840 stars 237 forks source link

addMarker insert order is not preserved with OverlappingMarkerSpiderfier #135

Open phlegx opened 7 years ago

phlegx commented 7 years ago

Hi!

If I use the map and load my markers without OverlappingMarkerSpiderfier the order of inserted markers is preserved. With OverlappingMarkerSpiderfier the addMarker seams to shuffle the order.

Why? How can I solve this problem?

jawj commented 7 years ago

I'm not sure what you mean by the order of the markers. Can you clarify? What problem is being caused? Screenshots or code samples might help.

phlegx commented 7 years ago

Hi @jawj! Example: All markers are in an ordered Array and all markers overlap's. I have two types of markers: red and green. The red markers are always at the beginning of the array. If I loop trough the array to add the marker to the map (normal Google Maps add marker function), the most upper marker is still green, because it is the last marker in the array. Until here all works fine but if I loop the same way over the array to add the marker to the OverlappingMarkerSpiderfier layer, the maps shows me some time a green marker and some times a red marker on top of overlapped markers. Why?

jawj commented 7 years ago

In general, the markers shown on top should be the ones lower down the screen (i.e. at lower latitude), and only in the case of a tie (i.e. identical latitudes) would I expect indeterminate results.

Your problem sounds like a Z index issue, but OMS only touches the Z indices when spiderfying, and restores them straight after.

I would need to see working examples both ways (with and without OMS in use) to investigate further. A service like JSFiddle might be useful to you here.