Skip to content

86 add markers

image image image

Adding markers to the map

Uncomment the following line to install leafmap if needed.

1
# %pip install -U "leafmap[vector]"
1
from leafmap import leafmap

Create an interactive map.

1
2
m = leafmap.Map()
m

Add a simple marker to the map.

1
m.add_markers(markers=[40, -100], shape="marker")

Add circle markers to the map.

1
m.add_markers(markers=[[40, -100], [35, -110]], shape="circle")

Customize circle markers.

1
2
3
4
5
6
7
8
m.add_markers(
    markers=[[40, -100], [35, -110]],
    shape="circle",
    radius=20,
    color="red",
    fill_color="#3388ff",
    fill_opacity=0.5,
)

Add country polygons to the map.

1
2
3
4
5
6
m = leafmap.Map()
countries = (
    "https://github.com/opengeos/datasets/releases/download/world/countries.geojson"
)
m.add_geojson(countries, layer_name="Countries", info_mode=None)
m

Add circle markers with popups to the map.

1
2
3
4
url = (
    "https://github.com/opengeos/datasets/releases/download/world/world_cities.geojson"
)
m.add_data(url, column="population", cmap="Blues", marker_radius=5, layer_name="Cities")