mickburkejnr
mickburkejnr

Reputation: 3690

How to display multiple markers for one location with Google Maps API?

I'm helping a colleague build a project that allows people to say where they are going (or have visited), and we've encountered a problem by where if two people are going to the same place, only one marker is displayed.

We then looked on Facebook, and we noticed that instead of displaying multiple markers on one location they instead display a circle with a number representing how many markers are there, like on the image below:

enter image description here

How can we replicate this for our own project? We are using the Google Maps API.

Cheers!

Upvotes: 1

Views: 1995

Answers (1)

yent
yent

Reputation: 1343

You can use whatever image you want for your markers, see https://developers.google.com/maps/documentation/javascript/reference#Marker

You can either use urls like http://doamin.tld/marker.php?number=42 for your markers, where the scripts generates the marker image (with some caching maybe), or generate all possible markers beforehand.

Another solution would be using svg to define the marker image using markerShapes, see https://developers.google.com/maps/documentation/javascript/reference#MarkerShape and marker's setShape method.

Upvotes: 2

Related Questions