Usage
You can try out leafmap by using Goolge Colab (
) or Binder (
) without having to install anything on your computer.
Launch Jupyter notebook
| conda activate geo
jupyter notebook
|
Use ipyleaflet plotting backend
Use folium plotting backend
| import leafmap.foliumap as leafmap
|
Create an interactive map
| m = leafmap.Map(center=(40, -100), zoom=4)
m
|
Customize map height
| m = leafmap.Map(height="450px")
m
|
Set control visibility
| m = leafmap.Map(draw_control=False, measure_control=False, fullscreen_control=False, attribution_control=True)
m
|
Change basemaps
| m = leafmap.Map(google_map="TERRAIN")
m.add_basemap("HYBRID")
m
|
Add XYZ tile layer
| m = leafmap.Map()
m.add_tile_layer(url="https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}", name="Google Satellite", attribution="Google")
m
|
Add WMS tile layer
| m = leafmap.Map()
naip_url = 'https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?'
m.add_wms_layer(url=naip_url, layers='0', name='NAIP Imagery', format='image/png', shown=True)
m
|
Prerequisites
| export HEREMAPS_API_KEY=YOUR-ACTUAL-API-KEY
|
| import leafmap.heremap as leafmap
|
Create an interactive map
| import os
api_key = os.environ.get("HEREMAPS_API_KEY") # read api_key from environment variable.
m = leafmap.Map(api_key=api_key, center=(40, -100), zoom=4)
m
|