Ahmed Maher
Ahmed Maher

Reputation: 35

Folium: Can I add multiple markers to the same geographical point?

I have a program that displays were people are; sometimes two people are exactly at the same point since we rely not on GPS signal but on places. So, in folium, when I add two markers to the same point, it overrides the past one completely, so I can't view the popup of the previous marker nor know about the existence of it.

So, is there a way to add multiple markers at the same point while still being able to view the two markers and their popups?

Upvotes: 1

Views: 3107

Answers (1)

kjacks21
kjacks21

Reputation: 123

MarkerCluster provides you the ability to show the number of markers in the same location. If you select the cluster, it will automatically expand the markers even if they have the same coordinates. From there, you can select the pop ups. Examples below

MarkerCluster cluster

MarkerCluster expanded to show points

MarkerCluster source code: https://github.com/python-visualization/folium/blob/5c5c0d6845c519d1383072e351770a9c2a0808e1/folium/plugins/marker_cluster.py#L16

MarkerCluster usage example: https://deparkes.co.uk/2016/06/24/folium-marker-clusters/

Upvotes: 2

Related Questions