opengeos / leafmap

A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment
https://leafmap.org
MIT License
3.22k stars 386 forks source link

add CircleMarker from folium #219

Closed notoriusjack closed 2 years ago

notoriusjack commented 2 years ago

Description

It would be a nice addition to add CircleMarker from folium to allow more control and display overlapping markers.

I have tried to use add_points_from_xy but without success. The following code snippet is what I am trying to replicate and works in folium

Source code

for i in range(len(filtered_data_street)):
    lat = filtered_data_street.iloc[i]['latitude']
    long = filtered_data_street.iloc[i]['longitude']
    popup_text = """Crime : {}<br>
                    Month : {}<br>"""
    popup_text = popup_text.format(filtered_data_street.iloc[i]['Crime type'],
                                   filtered_data_street.iloc[i]['Month']
                                   )
    if filtered_data_street.iloc[i]['Crime type'] == 'Violence and sexual offences':
        color = c_violence
        print(color)
        folium.CircleMarker(location=[lat, long], radius=10, popup=popup_text, fill=True, color='red').add_to(
            marker_cluster)
    elif filtered_data_street.iloc[i]['Crime type'] == 'Anti-social behaviour':
        color = c_violence
        print(color)
        folium.CircleMarker(location = [lat, long], radius=10, popup= popup_text, fill =True, color='orange').add_to(marker_cluster)
giswqs commented 2 years ago

See https://leafmap.org/notebooks/35_circle_markers