StephanGeorg / staticmaps

A Node.js library for creating map images with markers, polylines, polygons and text.
MIT License
170 stars 49 forks source link

Incorrect documentation for tileUrl with null value #95

Open reilem opened 6 days ago

reilem commented 6 days ago

The docs for tileUrl state:

(optional) Tile server URL for the map base layer or null for empty base layer. {x},{y},{z} or {quadkey} supported.

However this "or null" is no longer true since version 1.11.0.

This code:

import StaticMaps from 'staticmaps';

async function main() {
    const map = new StaticMaps({
        width: 600,
        height: 600,
        tileUrl: null,
        reverseY: true,
    });

    await map.render([0, 0], 2);

    await map.image.save("map.png");
}

main();

On version 1.10.0 and before used to render an empty image where every pixel had rgba value (0,0,0,0). This was useful for creating a blank image with annotations rendered which could then be overlayed on top of other maps. However, since version 1.11.0 this now creates this image:

map

Is it still possible to create empty layers? Or has this been removed? If this feature has been removed then maybe it would be nice to add this to the release notes as a breaking change and also to update the docs. Thanks!

reilem commented 5 days ago

For those interested I found a way to get transparent maps by using a fake url that does not point to anything, e.g. "https://fake-tiles.example.com/{z}/{x}/{y}.png" this returns 404s and will result in a transparent layer.