Summary
I have .geojson files and want to convert them (with tippecanoe / geobuf / other) to .mbtiles or .pbf files to serve them as vector tiles from a server (TileServer-GL / OpenMapTiles / other vector tile server) into Google Maps with Deck.GL's MVTLayer.
Expected results:
- To be able to serve from TileServer-GL .pbf file instead of .mbtiles file.
- To be able to serve from TileServer-GL multiple .mbtiles (or .pbf) files from a folder without explicitly starting it with a specific .mbtiles file.
Actual results:
- As presented below, I'm using Google Maps with Deck.GL MVTLayer integration with vector tiling to serve specific .mbtiles file from TileServer-GL, as collection of shapes or points.
- Didn't manage anything.
My attempts
const map = new google.maps.Map(document.getElementById('container'), {
center: { lat: 51.47, lng: 0.45 },
zoom: 10
});
const deckOverlay = new deck.GoogleMapsOverlay({
layers: [
new deck.MVTLayer({
//working
data: `http://localhost:8080/data/SA1_2016-AU-tippecanoe/{z}/{x}/{y}.pbf`,
//expected, but server NOT starting
//data: `http://localhost:8080/data/SA1_2016-AU-geobuf/{z}/{x}/{y}.pbf`,
minZoom: 0,
maxZoom: 23,
getLineColor: [1, 1, 1],
getFillColor: [0, 153, 76],
pickable: true,
autoHighlight: true,
onClick: info => info.object && console.log('onClick', info.object)
})
]
});
deckOverlay.setMap(map);
I'm running TileServer-GL from Docker, from the the folder that contains data files:
docker run --rm -it -v ${pwd}:/data -p 8080:80 maptiler/tileserver-gl --verbose --mbtiles SA1_2016-AU-tippecanoe.mbtiles
From Docker, I'm converting .geojson files to .mbtiles files through tippecanoe. However, it seems the conversion takes some time for bigger files. I'm obtaining a 890 MB .mbtiles file in aprox. 60 minutes from a 45 MB .geojson file with 57k features.
docker run -it --rm -v ${pwd}:/data tippecanoe:latest tippecanoe --output=/data/SA1_2016-AU-tippecanoe.mbtiles /data/SA1_2016-AU.geojson
I managed to faster convert a .geojson file directly to a .pbf file through geobuf (json2geobuf). I'm obtaining a 32 MB .pbf file in aprox. 37 seconds from a 45 MB .geojson file with 57k features.
json2geobuf SA1_2016-AU.geojson > SA1_2016-AU-geobuf.pbf
However, it seems i'm not able to directly serve .pbf files from TileServer-GL, nor from OpenMapTiles-Server.
I tried
docker run --rm -it -v ${pwd}:/data -p 8080:80 maptiler/tileserver-gl --verbose --mbtiles SA1_2016-AU-geobuf.pbf
but TileServer-GL not starting & i'm getting
ERROR: Metadata missing in the MBTiles.
Make sure SA1_2016-AU-geobuf.pbf is valid MBTiles
I also tried re-runing after creating locally a config.json file
docker run --rm -it -v ${pwd}:/data -p 8080:80 maptiler/tileserver-gl --verbose --mbtiles SA1_2016-AU-geobuf.pbf
docker run --rm -it -v ${pwd}:/data -p 8080:80 maptiler/tileserver-gl --verbose SA1_2016-AU-geobuf.pbf
config.json
{
"options": {
"paths": {
"root": "/usr/src/app/node_modules/tileserver-gl-styles",
"fonts": "fonts",
"styles": "styles",
"mbtiles": "/data"
}
},
"styles": {},
"data": {
"SA1_2016-AU-geobuf": {
"mbtiles": "SA1_2016-AU-geobuf.pbf"
}
}
}
but TileServer-GL not starting & i'm getting
SQLITE_NOTADB: file is not a database
On OpenMapTiles server I don't even find how to specify the input file (reference):
docker run --rm -it -v ${pwd}:/data -p 8080:80 klokantech/openmaptiles-server
My questions
- How can I directly serve .pbf files instead of .mbtiles files with TileServer-GL or OpenMapTiles servers?
- How can I use TileServer-GL to serve all the files (.mbtiles) form a folder, without explicitly starting it with a specific .mbtiles file
docker ... maptiler/tileserver-gl --mbtiles some-file.mbtiles
?