50 marker cluster
Creating a marker cluster with custom icons
Uncomment the following line to install leafmap if needed.
In [ ]:
Copied!
# !pip install leafmap
# !pip install leafmap
In [ ]:
Copied!
import leafmap
import leafmap
Create an interactive map.
In [ ]:
Copied!
m = leafmap.Map(center=[40, -100], zoom=4)
m = leafmap.Map(center=[40, -100], zoom=4)
Use sample datasets.
In [ ]:
Copied!
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'
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.
In [ ]:
Copied!
m.add_geojson(regions, layer_name='US Regions')
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.
In [ ]:
Copied!
m.add_points_from_xy(
cities,
x="longitude",
y="latitude",
color_column='region',
icon_names=['gear', 'map', 'leaf', 'globe'],
spin=True,
add_legend=True,
)
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.
In [ ]:
Copied!
m
m
Last update:
2023-09-22
Created: 2023-09-22
Created: 2023-09-22