staticmaps icon indicating copy to clipboard operation
staticmaps copied to clipboard

Incorrect documentation for tileUrl with null value

Open reilem opened this issue 1 year ago • 1 comments

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 avatar Nov 06 '24 19:11 reilem

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.

reilem avatar Nov 07 '24 08:11 reilem