Python Forum
Folium FastMarkerCluster
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Folium FastMarkerCluster
#1
I am plotting gun violence incidents in the U.S. with folium FastMarkerCluster. The code bellow does the job rather well.

lats2018 = guns2018['latitude'].tolist()
lons2018 = guns2018['longitude'].tolist()

locations = list(zip(lats2018, lons2018))
popups = ['lon:{}<br>lat:{}'.format(lons2018, lats2018) for (lats2018, 
lons2018) in locations]
icon_create_function = """\
function(cluster) {
return L.divIcon({
html: '<b>' + cluster.getChildCount() + '</b>',
className: 'marker-cluster marker-cluster-large',
iconSize: new L.Point(20, 20)
});
}"""

b = folium.Map(
location=[np.mean(lats2018), np.mean(lons2018)],
tiles='Cartodb Positron',
zoom_start=1
)

marker_cluster = MarkerCluster(
locations=locations, popups=popups,
overlay=True,
control=True,
icon_create_function=icon_create_function
)

marker_cluster.add_to(b)
folium.LayerControl().add_to(b)

b.save(outfile= "2018.html")
I'm looking for a way to add text to the markers - this is text I have scrapped from articles. I have been at this for nearly a week and feel like I've exhausted all resources. Any and all help about how to go about this is much appreciated. The texts are stored in the pandas df where the lon and lat also come from.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How can draw a real-time marker on map using folium/leaflet Jupyter notebook C3PO 0 2,389 Dec-22-2020, 07:04 PM
Last Post: C3PO
  no image displayed with folium and pandas Declaix 1 2,080 Oct-29-2020, 05:44 PM
Last Post: snippsat
  Folium: HeatMapWithTime is not displaying data point Vreni 0 5,682 Jun-06-2018, 07:24 AM
Last Post: Vreni

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020