Creating a marker cluster with custom icons
Uncomment the following line to install leafmap if needed.
# !pip install leafmap
import leafmap
Create an interactive map.
m = leafmap.Map(center=[40, -100], zoom=4)
Use sample datasets.
cities = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_cities.csv"
regions = "https://raw.githubusercontent.com/opengeos/leafmap/master/examples/data/us_regions.geojson"
Add a GeoJSON to the map.
m.add_geojson(regions, layer_name="US Regions")
Add a marker cluster to the map. The input can either be a string (representing file path or HTTP URL to a csv file) or a Pandas DataFrame.
The list of available icon names can be found at https://fontawesome.com/v4/icons.
Please note that the spin
parameter only supports the ipyleaflet backend. The folium backend does not support this.
m.add_points_from_xy(
cities,
x="longitude",
y="latitude",
color_column="region",
icon_names=["gear", "map", "leaf", "globe"],
spin=True,
add_legend=True,
)
Display the map.
m