Generate static map images/thumbnails as a web service. It can be used as a microservice in your project.
Building out of the box product for generating static map images as a web service as an alternative to the Google Static Map API.
This project follows Airbnb javascript style guide and enforced by "Eslint". Run npm run lint to validate style adhearance.
Images can be generated using URL parameters as follows.
<your baseurl>?markers=40.714728,-73.998672|63.259591,-144.667969&size=200x200
The above url will generate blow image.
Following features can be draw on a map using this API service.
- Markers
- Paths
- Polygons
- Texts
You can install this API as a docker image or as a bare Node.js web service
- Node.js API service
- Clone this project
- Install
npmdependencies usingnpm installornpm ci - Create configuration file by renaming
.env.sampleto.env - Configure variables in
.envfile - Start the web server using
npm start
- Docker image
-
Pull the docker image from Docker Hub
-
Run the docker container
Eg.docker container run -d \ -p 8080:8080 \ --volume /path/to/my/cache/folder:/cache \ gihan9a/staticmaps-service
-
- As a serverless solution @TODO
| Variable | Description | Default |
|---|---|---|
| PORT | Application port inside container | 8080 |
| IMAGE_FORMAT_DEFAULT | Default output image format | jpg |
| IMAGE_HEIGHT_MAX | Maximum output image height | 1999 |
| IMAGE_HEIGHT_MIN | Minium output image height | 1 |
| IMAGE_WIDTH_MAX | Maximum output image width | 1999 |
| IMAGE_WIDTH_MIN | Minimum output image width | 1 |
| MARKER_COLOR_DEFAULT | Default marker color | orange |
| PATH_COLOR_DEFAULT | Default path color | #000000BB |
| POLYGON_FILL_COLOR_DEFAULT | Default polygon fill color | #00000088 |
| TEXT_COLOR | Default text (stroke) color | #000000BB |
| TEXT_FILL_COLOR | Default text fill color | #000000BB |
| TEXT_FONT | Default font family | Arial |
| TEXT_SIZE | Default text size | 12 |
| TEXT_WIDTH | Default text stoke width | 1 |
| ZOOM_MAX | Maximum zoom avaialble | 20 |
| ZOOM_MIN | Minimum zoom avaialble | 1 |
/cache directory can be mounted as a volume to persist image caches
Tests can be found in /test directory. Tests can be run using npm test. Please make sure you have working internet connection when running integration tests.
Please refer the Wiki page for detailed use of the API.
Contributions are welcome to the project. Please kindly go through the contributing guidelines
Awesome StaticMaps npm module by Stephan Georg
Map images and data provide by Openstreetmap.org
Pittsburgh Map icon by Icons8
This work is licensed under the terms of the MIT license.
For a copy, see https://opensource.org/licenses/MIT.
Map images are provided by © OpenStreetMap contributors

