Skip to main content

Static Map 3

Static Map 3 is a fork of Static Map, a small, python-based library for creating map images with lines and markers.
The main purpose of this fork is to fix error handling on tile requests, to allow interrupting the execution (see PR on the original repository).

Changes since the fork are detailed in CHANGELOG.md.

Example

from staticmap3 import StaticMap, Line

m = StaticMap(300, 400, 10)
m.add_line(Line(((13.4, 52.5), (2.3, 48.9)), 'blue', 3))
image = m.render()
image.save('map.png')

This will create a 300px x 400px map with a blue line drawn from Berlin to Paris.

Map with Line from Berlin to Paris

Installation

Static Map 3 is a small library, all it takes is python and three python packages: Pillow, requests and cachecontrol.

To install Static Map 3:

pip install git+https://github.com/SamR1/staticmap.git

To use Filecache as storage backend for cache:

pip install git+https://github.com/SamR1/staticmap.git@main#egg=staticmap3[filecache]

The default directory for cache is .staticmap_cache. It can be changed by exporting the environment variable STATICMAP_CACHE_DIR.

Usage

Create a new map instance:

m = StaticMap(width, height, padding_x, padding_y, url_template, tile_size)
parameter description
width width of the image in pixels
height height of the image in pixels
padding_x (optional) minimum distance in pixel between map features (lines, markers) and map border
padding_y (optional) minimum distance in pixel between map features (lines, markers) and map border
url_template (optional) the tile server URL for the map base layer, e.g. https://tile.openstreetmap.org/{z}/{x}/{y}.png
tile_size (optional) tile size in pixel, usually 256

Add a line:

line = Line(coordinates, color, width))
m.add_line(line)
parameter description
coordinate a sequence of lon/lat pairs
color a color definition Pillow supports
width the stroke width of the line in pixel
simplify whether to simplify coordinates, looks less shaky, default is true

Add a map circle marker:

marker = CircleMarker(coordinate, color, width))
m.add_marker(marker)
parameter description
coordinate a lon/lat pair: e.g. (120.1, 47.3)
color a color definition Pillow supports
width diameter of marker in pixel

Add a polygon:

polygon = Polygon(coordinates, fill_color, outline_color, simplify)
m.add_polygon(polygon)
parameter description
coordinate a lon/lat pair: e.g. [[9.628, 47.144], [9.531, 47.270], [9.468, 47.057], [9.623, 47.050], [9.628, 47.144]]
fill_color a color definition Pillow supports
outline_color a color definition Pillow supports
simplify whether to simplify coordinates, looks less shaky, default is true

Samples

Show Position on Map

from staticmap3 import StaticMap, CircleMarker

m = StaticMap(
    200, 200, url_template='https://tile.openstreetmap.org/{z}/{x}/{y}.png'
)

marker_outline = CircleMarker((10, 47), 'white', 18)
marker = CircleMarker((10, 47), '#0036FF', 12)

m.add_marker(marker_outline)
m.add_marker(marker)

image = m.render(zoom=5)
image.save('marker.png')

Position IconMarker on a Map

Show Ferry Connection

from staticmap3 import StaticMap, Line

m = StaticMap(200, 200, 80)

coordinates = [[12.422, 45.427], [13.749, 44.885]]
line_outline = Line(coordinates, 'white', 6)
line = Line(coordinates, '#D2322D', 4)

m.add_line(line_outline)
m.add_line(line)

image = m.render()
image.save('ferry.png')

Ferry Connection Shown on a Map

Show Icon Marker

from staticmap3 import StaticMap, IconMarker

m = StaticMap(240, 240, 80)
icon_flag = IconMarker(
    (6.63204, 45.85378), './samples/icon-flag.png', 12, 32
)
icon_factory = IconMarker(
    (6.6015, 45.8485), './samples/icon-factory.png', 18, 18
)
m.add_marker(icon_flag)
m.add_marker(icon_factory)
image = m.render()
image.save('icons.png')

Ferry Connection Shown on a Map

Alternatives

With papermap there is also a spin-off project dedicated to print maps.

Licence

Static Map 3 is open source and licensed under Apache License, Version 2.0

The map samples on this page are made with OSM data, © OpenStreetMap contributors

Metadata

Release files for staticmap3 0.2.1

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

Source distribution (sdist)

Source distribution for staticmap3 0.2.1
File Size Uploaded Provenance Actions
staticmap3-0.2.1.tar.gz 9.8 kB With provenance Details for staticmap3-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for staticmap3 0.2.1
File Interpreter ABI Platform Actions
staticmap3-0.2.1-py3-none-any.whl Python 3 none any Details for staticmap3-0.2.1-py3-none-any.whl

Total release size: 19.1 kB

Release files / staticmap3-0.2.1.tar.gz

Download URL staticmap3-0.2.1.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f2bbfaa2623bf251774e82e79bbbca432595a32e925ff636c38580fa9bdbe298
BLAKE2b-256 checksum
How to use checksums
560a6619c66c58ca35e3b23cc71ff65bdd51846c2869416add40f0fa43b4852e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Release files / staticmap3-0.2.1-py3-none-any.whl

Download URL staticmap3-0.2.1-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad71fbd30f6dd99d7de21fb604c1cd60bcc56e94feab2da3307aa2b9f10495cb
BLAKE2b-256 checksum
How to use checksums
0edf091fad8f419d58c78d72dc3041fd746f43b6f5c80c9c2e3afc448f550f69
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

Security for staticmap3 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for staticmap3-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 29, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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