Skip to main content

Mapkick Static

Create beautiful static maps with one line of Python. No more fighting with mapping libraries!

See it in action

:fire: For JavaScript maps, check out Mapkick.py

Build Status

Installation

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.

Django

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 }}

Flask

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 }}

Maps

Point map

Point map
StaticMap([{'latitude': 37.7829, 'longitude': -122.4190}])

Area map

Area map
StaticAreaMap([{'geometry': {'type': 'Polygon', 'coordinates': ...}}])

Data

Data can be an array

StaticMap([{'latitude': 37.7829, 'longitude': -122.4190}])

Point Map

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'
}

Area Map

Use geometry with a GeoJSON Polygon or MultiPolygon

You can specify a color for each data point

{
    'geometry': {'type': 'Polygon', 'coordinates': ...},
    'color': '#0090ff'
}

Options

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')

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

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

Release files for mapkick-static 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for mapkick-static 0.1.0
File Interpreter ABI Platform
mapkick_static-0.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / mapkick_static-0.1.0-py2.py3-none-any.whl

Download URL mapkick_static-0.1.0-py2.py3-none-any.whl
Size 5.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
1818271ef0e202c725b492a463a421d585d27d7cbe55d17ab0d7f86e8830b58f
BLAKE2b-256 checksum
How to use checksums
8d0570b8441cc5eb01c6079fe92b8fa880df03a39e169a66e972cdae7fefd1cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.6

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page