Create beautiful static maps with one line of Python. No more fighting with mapping libraries!
For JavaScript maps, check out Mapkick.py
Run:
pip install mapkick-static
Then follow the instructions for your web framework:
Mapkick Static uses the Mapbox Static Images API. Create a Mapbox account to get an access token and set os.environ['MAPBOX_ACCESS_TOKEN']
in your environment.
Create a map in a view
from mapkick.static import StaticMap
def index(request):
map = StaticMap([{'latitude': 37.7829, 'longitude': -122.4190}])
return render(request, 'home/index.html', {'map': map})
And add it to the template
{{ map }}
Create a map in a route
from mapkick.static import StaticMap
def index():
map = StaticMap([{'latitude': 37.7829, 'longitude': -122.4190}])
return render_template('home/index.html', map=map)
And add it to the template
{{ map }}
Point map
StaticMap([{'latitude': 37.7829, 'longitude': -122.4190}])
Area map
StaticAreaMap([{'geometry': {'type': 'Polygon', 'coordinates': ...}}])
Data can be an array
StaticMap([{'latitude': 37.7829, 'longitude': -122.4190}])
Use latitude
or lat
for latitude and longitude
, lon
, or lng
for longitude
You can specify a color for each data point
{
'latitude': ...,
'longitude': ...,
'color': '#f84d4d'
}
Use geometry
with a GeoJSON Polygon
or MultiPolygon
You can specify a color for each data point
{
'geometry': {'type': 'Polygon', 'coordinates': ...},
'color': '#0090ff'
}
Width and height
StaticMap(data, width=800, height=500)
Alt text
StaticMap(data, alt='Map of ...')
Marker color
StaticMap(data, markers={'color': '#f84d4d'})
Map style
StaticMap(data, style='mapbox/outdoors-v12')
View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/ankane/mapkick-static.py.git
cd mapkick-static.py
pip install -r requirements.txt
pytest