Skip to content

Add icon

image image image

Add a directional icon to the map

The notebook demonstrates how to add a directional icon to the map.

Uncomment the following line to install leafmap if needed.

1
# %pip install "leafmap[maplibre]"
1
import leafmap.maplibregl as leafmap

To run this notebook, you will need an API key from MapTiler. Once you have the API key, you can uncomment the following code block and replace YOUR_API_KEY with your actual API key. Then, run the code block code to set the API key as an environment variable.

1
2
# import os
# os.environ["MAPTILER_KEY"] = "YOUR_API_KEY"
1
2
3
4
5
6
7
8
9
m = leafmap.Map(style="3d-terrain")
url = "https://github.com/opengeos/datasets/releases/download/hydrology/streams.geojson"
m.add_geojson(url, name="Streams")
image = "https://i.imgur.com/ZMMvXuT.png"
m.add_arrow(
    source="Streams", image=image, icon_size=0.1, symbol_placement="line", minzoom=10
)
m.add_layer_control()
m
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
m = leafmap.Map(style="3d-terrain")
url = "https://github.com/opengeos/datasets/releases/download/vector/hike_gps_trace_line.geojson"
m.add_geojson(url, name="Hiking Trail")
image = "https://i.imgur.com/ZMMvXuT.png"
m.add_arrow(
    source="Hiking Trail",
    image=image,
    icon_size=0.1,
    symbol_placement="line",
    minzoom=10,
)
m.add_layer_control()
m
1