UNPKG

@jorgenphi/staticmaps

Version:

A Node.js library for creating map images with markers, polylines, polygons and text.

45 lines (40 loc) 1.11 kB
const StaticMaps = require('./dist/StaticMaps'); async function test() { const min_zoom = 2; const max_zoom = 10; const options = { width: 1200, height: 800, tileLayers: [ { tileUrl: 'https://api.mapbox.com/styles/v1/0xae/cl34x63rb004i15nt3yuo2zhv/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoiMHhhZSIsImEiOiJjbDM0d3Vybm0yMTcyM2NtaGNpZGh1dXF5In0.XMYfA_r12W7z3ut_4Klg1w', }, { tileUrl: 'https://api.weather.com/v3/TileServer/tile/radar?ts=1652490900&xyz={x}:{y}:{z}&apiKey=e1f10a1e78da46f5b10a1e78da96f525', disableCache: true, }, ], zoomRange: { min: min_zoom, max: max_zoom, }, tileCacheFolder: './tile_cache/', }; const map = new StaticMaps(options); const polygon = { coords: [ [-98.76, 32.16], [-98.88, 32.5], [-98.48, 32.51], [-98.48, 32.3], [-98.76, 32.16], ], color: 'black', width: 3, }; console.log(polygon); map.addPolygon(polygon); await map.render(); await map.image.save(`${new Date().getTime()}.png`, { compressionLevel: 9 }); } test();