Herman Schaaf
Herman Schaaf

Reputation: 48475

Spreading markers out as necessary in Google Maps

I'm displaying many (hundreds) of markers at a time in a given viewport in Google Maps. Often, this leads to markers being drawn over each other.

Since the exact positions aren't as important at zoom levels where so many markers are drawn, is there a library or piece of code that allows markers to dynamically update their position based on whether they are overlapping with other markers or not? As the user zooms in (and markers becomes more sparse), the markers will then move closer to their real positions.

And yes, I know about groupings, marker clusterings, etc. Those solutions aren't appropriate in my situation, since it is important that all markers be displayed at all times. And in actuality, I am already using those techniques as well, where appropriate. I'm using the Javascript V3 API.

Upvotes: 0

Views: 375

Answers (1)

winwaed
winwaed

Reputation: 7829

You probably need to implement your own clustering algorithm - I think Google Maps let's you implement your own strategy (I know Bing Maps does, and typical they copy each other within 6 months or so of a new feature being implemented).

Note that for lots of dense pushpins, your constrains of separation but displaying all pins, are in conflict.

as for a strategy, my first thought is an annealing type of algorithm, although it probably isn't very fast. Basically each pushpin would exert a force on surrounding pushpins within a certain distance. iterate until sufficiently stable.

Upvotes: 2

Related Questions