Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rrainn/maptoimage
https://github.com/rrainn/maptoimage
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/rrainn/maptoimage
- Owner: rrainn
- License: mit
- Created: 2023-12-27T04:04:54.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-27T01:43:12.000Z (4 months ago)
- Last Synced: 2024-12-09T16:55:59.662Z (30 days ago)
- Language: TypeScript
- Size: 146 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MapToImage
## Description
This is a Node.js package that allows you to convert a map to an image. You can set the dimensions of the image, the zoom level, the center of the map, and the tile servers you wish to use.
## Installation
```bash
npm install maptoimage
```## Usage
```js
const { mapToImage } = require("maptoimage");
const fs = require("fs");(async () => {
const img = mapToImage({
"image": {
"dimensions": {
"width": 1280,
"height": 720
}
},
"map": {
"center": {
"lat": 39.67321,
"lng": -104.95140
},
"zoom": 5,
"layers": [
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
// https://mesonet.agron.iastate.edu/GIS/ridge.phtml
"https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/ridge::USCOMP-N0Q-0/{z}/{x}/{y}.png",
async (z, x, y) => {
const buffer = await fs.promises.readFile("tile.png");
return buffer;
}
]
}
});
fs.writeFileSync("map.png", img.png().toBuffer());
})();
```## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
Please remember that the tile servers you use may have their own licenses.