Map generator service
Generate image in png format for the given sets of features GeoJSON.
Demo
GeoJSON: Click to view
Result:
Run server and go to http://127.0.0.1:3000/image?data={%20%22t...
Installation
yarn
Usage
Env variables
name | description | required | default |
---|---|---|---|
APP_SERVER_PORT | Server port | false | 3000 |
APP_MAP_SERVICE_MAPBOX_TOKEN | MapBox token | true | - |
APP_MAP_SERVICE_WEB_PORT | Web application port | false | 8080 |
Run server
To run server required is installed Chrome or Chromium supported headless mode with GPU acceleration.
Required installed Node.js in version 8 or later.
export APP_MAP_SERVICE_MAPBOX_TOKEN={{MAPBOX_TOKEN}}
node src
Endpoints
GET /image
query parameters:
- data (JSON): GeoJSON of type FeatureCollection (required)
- width (number): width of result image FeatureCollection (optional)
- height (number): height of result image (optional)
Example data
GeoJSON:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
19.003279209136963,
50.25621233113204
],
[
19.003483057022095,
50.25593794866982
],
[
19.004191160202026,
50.256164314315235
],
[
19.00386929512024,
50.25634266224804
],
[
19.003279209136963,
50.25621233113204
]
]
]
}
}
]
}
Run with Docker
Application uses Chromium in headless mode to generate maps, and additionaly required is GPU acceleration. Docker doesn't support GPU, so to run application in container is needed use nvidia-docker.