maposter library

Turn a city name into a minimalist OpenStreetMap poster.

Geocoding, Overpass map data, Mercator projection, CustomPainter rendering, and PNG/PDF export — framework-agnostic, with pluggable caching.

Classes

CacheStore
Pluggable key/value cache for geocoding and map-data results.
CancelToken
Controls cancellation of Dio's requests.
CityCoordinates
A geocoded location: latitude/longitude plus the resolved place names returned by Nominatim.
GeocodingRepository
InMemoryCacheStore
Default store: caches for the lifetime of the process, in memory.
MapData
The full set of rendered map geometry for one poster: roads, water and park features, plus the bounds used to project them onto the canvas.
MapDataProgress
Progress emitted by MaposterEngine.fetchMapData (and the underlying repository) as it starts each MapDataStage. Use it to drive a staged progress UI — the first-time fetch of a city involves several slow, rate-limited network calls.
MapDataRepository
MapFeature
A filled polygon (e.g. a lake or park). rings holds one or more closed rings: the first is the outer ring, any others are holes.
MaposterConfig
Configuration for MaposterEngine.
MaposterEngine
Entry point for the map-poster engine.
MaposterPainter
Paints a finished map poster onto a Canvas: background, water, parks, roads (batched by RoadType), gradient fades, and the city/country/ coordinate text labels. Use directly in a CustomPaint, or via MaposterEngine.buildPainter / MaposterEngine.exportPng.
MapTheme
A color theme for a poster: background, text, gradient, water/parks fills, and a color per road type. Build one from a JSON map (MapTheme.fromJson) or from hex strings in code (MapTheme.fromHex).
Mercator
Web Mercator projection helpers: project lat/lon to metres or screen offsets, compute bounding boxes, and the aspect-ratio over-fetch radius.
NoopCacheStore
Disables caching entirely — every read misses.
PosterExporter
Rasterizes a MaposterPainter to a high-resolution PNG and wraps a PNG in a single-page PDF. Guards against excessively large export dimensions.
RoadSegment
A single road as an ordered list of lat/lon points, tagged with its type.
ThemeRepository

Enums

DioExceptionType
The exception enumeration indicates what type of exception has happened during requests.
FeatureType
Filled-polygon feature class (water bodies or parks/greenery).
MapDataStage
The map-data fetch stage a MapDataProgress event refers to.
RoadType
Road class, mapped from OpenStreetMap highway tags. Drives stroke width and color when rendering.

Extensions

CityCoordinatesPatterns on CityCoordinates
Adds pattern-matching-related methods to CityCoordinates.

Typedefs

LatLon = (double, double)
A latitude/longitude pair, in degrees.
LatLonBounds = ({double east, double north, double south, double west})
A geographic bounding box, in degrees.
MapDataProgressCallback = void Function(MapDataProgress progress)
Callback invoked as each map-data stage begins.

Exceptions / Errors

AppException
Base type for all errors thrown by the engine. switch over the sealed subtypes to handle specific failures, or read message for a user-facing string.
AssetException
A bundled asset (e.g. a theme JSON) could not be loaded or was invalid.
CacheException
Reading from or writing to the cache store failed.
DioException
DioException describes the exception info when a request failed.
GeocodingException
Geocoding (Nominatim) failed or returned no match.
NetworkException
A network/HTTP failure. statusCode is the response status when available.
OverpassException
An Overpass map-data request failed.
RenderException
Rendering or encoding the poster image failed.