All Projects β†’ jperelli β†’ osm-static-maps

jperelli / osm-static-maps

Licence: GPL-2.0 license
Openstreetmap static maps is a nodejs lib, CLI and server open source inspired on google static map service

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to osm-static-maps

osm-geojson
πŸ”° Get GeoJSON of a OpenStreetMap's relation from the API.
Stars: ✭ 42 (-67.69%)
Mutual labels:  geojson, maps, openstreetmap
geofeatures2
A lightweight, high performance geometry library in Swift.
Stars: ✭ 18 (-86.15%)
Mutual labels:  geojson, geometry, polygon
Mapbox Gl Native Android
Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL
Stars: ✭ 135 (+3.85%)
Mutual labels:  geojson, maps, openstreetmap
Mapbox Gl Native
Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
Stars: ✭ 4,091 (+3046.92%)
Mutual labels:  geojson, maps, openstreetmap
Country Iso
πŸ—Ί Get the ISO 3166-1 alpha-3 country code from geographic coordinates.
Stars: ✭ 141 (+8.46%)
Mutual labels:  geojson, maps
Kepler
The open source full-stack geosocial network platform
Stars: ✭ 125 (-3.85%)
Mutual labels:  geojson, openstreetmap
Geojsonify
Easily add GeoJson layers to your Maps
Stars: ✭ 141 (+8.46%)
Mutual labels:  geojson, maps
Mapstore2
Modern webmapping with OpenLayers, Leaflet and React
Stars: ✭ 251 (+93.08%)
Mutual labels:  geojson, maps
Leaflet Geoman
πŸ‚πŸ—ΊοΈ The most powerful leaflet plugin for drawing and editing geometry layers
Stars: ✭ 1,088 (+736.92%)
Mutual labels:  geojson, polygon
Mapboxstatic.swift
Static map snapshots with overlays in Swift or Objective-C on iOS, macOS, tvOS, and watchOS
Stars: ✭ 162 (+24.62%)
Mutual labels:  geojson, openstreetmap
echarty
Minimal R/Shiny Interface to ECharts.js
Stars: ✭ 49 (-62.31%)
Mutual labels:  geojson, maps
Geoswift
The Swift Geometry Engine.
Stars: ✭ 1,267 (+874.62%)
Mutual labels:  geojson, maps
Indonesia Postal And Area
Indonesia Postal Code & Area (BPS)
Stars: ✭ 64 (-50.77%)
Mutual labels:  geojson, geometry
Geo Maps
πŸ—Ί High Quality GeoJSON maps programmatically generated.
Stars: ✭ 1,098 (+744.62%)
Mutual labels:  geojson, maps
planetiler
Flexible tool to build planet-scale vector tilesets from OpenStreetMap data fast
Stars: ✭ 823 (+533.08%)
Mutual labels:  maps, openstreetmap
L7
🌎 Large-scale WebGL-powered Geospatial Data Visualization analysis framework which relies on Mapbox GL or AMap to render basemaps.
Stars: ✭ 2,517 (+1836.15%)
Mutual labels:  geojson, polygon
osmscout-sailfish
OSM Scout for Sailfish OS (offline maps and navigation)
Stars: ✭ 42 (-67.69%)
Mutual labels:  maps, openstreetmap
osm-extracts
Each day, OSM Extracts by Interline mirrors the entire OpenStreetMap planet and creates city and region sized extracts
Stars: ✭ 34 (-73.85%)
Mutual labels:  maps, openstreetmap
Shape-Your-Music
A web application for drawing music.
Stars: ✭ 106 (-18.46%)
Mutual labels:  geometry, polygon
Osm2geojson
Convert OSM and Overpass JSON to GeoJSON
Stars: ✭ 25 (-80.77%)
Mutual labels:  geojson, openstreetmap

osm-static-maps

Openstreetmap static maps is a nodejs lib, CLI and server open source inspired on google static map service

Here you have a demo. Also a dynamic version of the demo, for testing purposes.

How to use

1. CLI

sudo npm i -g osm-static-maps
osmsm --help
osmsm -g '{"type":"Point","coordinates":[-105.01621,39.57422]}' > map.png
  • note: if you have this error trying to install globally Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/osm-static-maps/node_modules/puppeteer/.local-chromium', it's caused by this pupeteer issue puppeteer/puppeteer#367, you can workaround by installing globally with the unsafe-perm flag:
sudo npm i -g osm-static-maps --unsafe-perm=true

2. nodejs library

npm install osm-static-maps
// index.js old school
osmsm = require('osm-static-maps');
osmsm({geojson: geojson})
  .then(function(imageBinaryBuffer) { ... })
  .catch(function(error) { ... })

// index.js modern style (also supports typescript)
import osmsm from 'osm-static-maps'
const imageBinaryBuffer = await osmsm({geojson})

3. Standalone sample server

sudo npm i -g osm-static-maps
osmsm serve

Or you can use docker-compose

git clone [email protected]:jperelli/osm-static-maps.git
cd osm-static-maps
docker-compose up

4. Cloud service

You can use the heroku-hosted alternative directly here

We are currently in the cloud beta, contact me directly at [email protected] so I can give you access to the cloud service.

API Reference

All parameters have a short and long version. The short version can be used only with the shell CLI. The long version can be used with the library and can be passed to the app server as GET query params, or POST json body (remember to set the header Content-Type: application/json)

Parameter Description Default Value
g geojson geojson object to be rendered in the map undefined
f geojsonfile filename or url to read geojson data from (use '-' to read from stdin on CLI) undefined
H height height in pixels of the returned img 600
W width height in pixels of the returned img 800
c center center of the map lon,lat floats string (center of the geojson) or '-57.9524339,-34.921779'
z zoom zoomlevel of the leaflet map if vectorserverUrl available, use 12 else 20
Z maxZoom max zoomlevel of the leaflet map 17
A attribution attribution legend 'osm-static-maps / Β© OpenStreetMap contributors'
t tileserverUrl url of a tileserver 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
m vectorserverUrl url of a vector tile server (MVT style.json) undefined
M vectorserverToken token of the vector tile server (MVT) 'no-token'
D renderToHtml returns html of the webpage containing the map (instead of a binary image) false
F type format of the image returned ('jpeg'/'png') 'png'
q quality quality of the image returned (0-100, only for jpg) 100
x imagemin enable lossless compression with optipng / jpegtran false
X oxipng enable losslsess compression with oxipng false
a arrows render arrows to show the direction of linestrings false
s scale enable render a scale ruler (boolean or a json options object) false
T timeout miliseconds until page load throws timeout 20000
k markerIconOptions set marker icon options (a json options object) *see note undefined (leaflet's default marker)
S style style to apply to each feature (a json options object) *see note undefined (leaflet's default)
e haltOnConsoleError throw error if there is any console.error(...) when rendering the map image false
  • Note on markerIconOptions: it's also accepted a markerIconOptions attribute in the geojson feature, for example {"type":"Point","coordinates":[-105.01621,39.57422],"markerIconOptions":{"iconUrl":"https://leafletjs.com/examples/custom-icons/leaf-red.png"}}

  • Note on style: it's also accepted a pathOptions attribute in the geojson feature, for example {"type":"Polygon","coordinates":[[[-56.698,-36.413],[-56.716,-36.348],[-56.739,-36.311]]],"pathOptions":{"color":"#FF5555"}} (also remember that the # char needs to be passed as %23 if you are using GET params)

Design considerations & architecture

Read the blogpost on the creation of this library and how it works internally

LICENSE

  • GPLv2

Credits

Specially to the contributors of

  • OpenStreetMap
  • Leaflet
  • Puppeteer
  • ExpressJS
  • Handlebars
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].