A client library for VersaTiles containers.
npm i -s versatiles
const versatiles = require("versatiles");
const fs = require("fs");
const c = versatiles("https://example.org/planet.versatiles").getTile(z,x,y, function(err, buffer){
fs.writeFile("tile."+c.header.tile_format, buffer, function(){});
});
src
: can be a file path or url pointing to a versatiles container.tms
: settrue
if versatiles container uses tms scheme with inverted Y indexheaders
: additional request headers sent to the server when src ishttp
base
: base url for relative urls in style.json / tile.json when the builtin webserver is started
Get a tile as buffer from a versatiles container
Decompress a buffer, with type bein gzip
, br
or null, obtainable from header.tile_precompression
Get the header of a versatiles container
Get the metadata of a versatiles container
Get the available zoom levels of a versatiles container as an array of integers
[ 0, 1, 2, ... ];
Get the bounding box as an array of floats in the order WestLon
, SouthLat
, EastLon
, NorthLat
.
[
13.07373046875,
52.32191088594773,
13.77685546875,
52.68304276227742
]
Start a rudimentary webserver delivering tiles and metadata. Arguments are passed on to http.server.listen()
versatiles("./some.versatiles").server(8080, "localhost", function(){
console.log("Listening on http://localhost:8080/");
});
/{z}/{x}/{y}
get tile/tile.json
get TileJSON/style.json
get minimal StyleJSON/
Display map in Browser with maplibre-gl-js and maplibre-gl-inspect
When called directly, versatiles can act as a standalone server.
This is for testing purposes, please feel discouraged from using this in a production environment.
npm i -g versatiles
versatiles-server <file|url> [--tms] [--port <port>] [--host <hostname|ip>] [--base https://example.org] [--header-<header-key> <header-value>]
npm i versatiles
node node_modules/versatiles/versatiles.js <file|url> [--tms] [--port <port>] [--host <hostname|ip>] [--base https://example.org] [--header-<header-key> <header-value>]