StaticMap

raw JSON →
0.5.7 verified Fri May 01 auth: no python maintenance

A small, Python-based library for creating static map images with lines and markers. Current version 0.5.7 (last released March 2020). Development appears to be in maintenance mode with no recent releases.

pip install staticmap
error ModuleNotFoundError: No module named 'staticmap'
cause Library not installed or installed in wrong environment.
fix
Run: pip install staticmap
error TypeError: argument of type 'NoneType' is not iterable
cause Tile URL template is not set or tiles cannot be fetched.
fix
Specify a valid url_template: m = StaticMap(600, 400, url_template='https://tile.openstreetmap.org/{z}/{x}/{y}.png')
gotcha Coordinates are (lon, lat) order, not (lat, lon). Many users incorrectly pass (lat, lon) leading to markers in wrong locations.
fix Always pass (longitude, latitude) to StaticMap, CircleMarker, and Line.
gotcha Tile fetching requires an internet connection. Offline usage is not supported natively.
fix Ensure network access or pre-download tiles manually.

Creates a map with a marker and a line, saved to map.png.

from staticmap import StaticMap, CircleMarker, Line

m = StaticMap(600, 400, url_template='https://tile.openstreetmap.org/{z}/{x}/{y}.png')
marker = CircleMarker((13.405, 52.52), 'blue', 12)
m.add_marker(marker)
line = Line([(13.4, 52.5), (13.41, 52.53)], 'red', 2)
m.add_line(line)
image = m.render()
image.save('map.png')