A client library for VersaTiles
npm install versatilesA client library for VersaTiles containers.
npm i -s versatiles
`` js
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
* : set true if versatiles container uses tms scheme with inverted Y indexheaders
* : additional request headers sent to the server when src is httpbase
* : 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
` js`
[ 0, 1, 2, ... ];
Get the bounding box as an array of floats in the order WestLon, SouthLat, EastLon, NorthLat.
` js`
[
13.07373046875,
52.32191088594773,
13.77685546875,
52.68304276227742
]
Start a rudimentary webserver delivering tiles and metadata. Arguments are passed on to http.server.listen()
` js`
versatiles("./some.versatiles").server(8080, "localhost", function(){
console.log("Listening on http://localhost:8080/");
});
#### Routes
* /{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.
` sh`
npm i -g versatiles
versatiles-server
` sh``
npm i versatiles
node node_modules/versatiles/versatiles.js