In a mapbox-gl map, given the source:

map.addSource('myTileSource', {
    type: "vector",
    tiles: "url to source tiles.pbf",

is it possible to get all the layers and/or metadata for the tiles inside that source? This is possible in node with node-mbtiles, but wondering if it is possible directly in mapbox-gl via javascript? Something like map.getLayersFromSource would be awesome.

  • Mapbox has simple tools that take a tile source and convert it to GeoJSON, such as github.com/mapbox/vt2geojson which may be useful here. – kuanb Feb 6 at 22:58

Since you have a .MBTiles file you can use TileServer GL to serve up your data. This tiny web server has a mode called Inspect or X-Ray which will sniff the vector layers in the .MBTiles and display a basic style so you can see the data.

TileServer GL uses Javascript to show the vector data available at each zoom level. It also has a mouse event handler to show you the metadata of each feature.

After installing tileserver-gl or tileserver-gl-light you can then navigate to the Inspect mode by navigating to

See this link for more information on how to install

tileserver-gl-xray-inspect Example of Inspect mode from TileServer GL

  • What is the recommended server requirements for Tileserver-gl-light? Should I expect performance similar to mbtiles-server which uses node-mbtiles? I have tileserver PHP installed and the performance for serving of vector tiles from mbtiles is not good, though the server CPU and memory are very limited. Finally, can Tileserver-gl-light watch a directory or do I have to specify each mbtiles individually? – malcolm Jan 20 '17 at 9:54
  • I would refer you to the docs github.com/klokantech/tileserver-gl This is a newer project than the PHP version, so it may address some of your questions. – RobLabs Jan 20 '17 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.