3

I have downloaded many vector tiles in the mbtiles format from OpenMapTiles. The reason I did that is because I will be using them on a station that cannot have an internet connection at all.

I would like in the end to see these tiles with leaflet on a browser, but it seems that the plugin for leaflet only considers raster-based tiles and not vector-based tiles, or so I thought until I saw Loading vector tile layer in Leaflet map? here on GIS. However, it seems to be outdated and the JSFiddle doesn't work anymore... So I figured I would try it out myself, but it did not work. So I am currently inclined to think that this plugin only works with raster tiles and not vector ones.

I also considered then converting my tiles to PNG so that I could use them with leaflet and used mbutils for that, as suggested on GIS at Finding good Mbtiles to png tiles converter? but obviously none of the generated PNGs are readable by my OS or leaflet as mbutils doesn't raster them.

I have two questions depending on how you advise me:

  1. Is it possible to read vector tiles with leaflet?
  2. If not, how is it possible to convert them to raster?

I cannot use commercial services like maptobox or any similar services, this the reason why I was trying to have everything running on my machine right away.

I have seen before the vector grid from leaflet. It says that it can read vector-tile files but when you click on it to get the documentation it says:

This library reads Mapbox Vector Tiles and allows access to the layers and features.

As for the Leaflet.TileLayer the documentation says that TileLayer is for rasters.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
LBes
  • 163
  • 1
  • 10
  • It is possible, check out these links. https://github.com/Leaflet/Leaflet.VectorGrid https://esri.github.io/esri-leaflet/api-reference/layers/vector-basemap.html I have used the Esri tiles but not created any. – Bill Chappell Aug 14 '18 at 18:28
  • @BillChappell are the two links connected? Cause I cannot use any kind of hosting service (like Esri then I suppose). The first link you provided says that it can read vector-tile but then when I click on it I get that "This library reads Mapbox Vector Tiles and allows access to the layers and features." – LBes Aug 14 '18 at 18:32
  • Before VectorGrid, loading vector tiles in Leaflet could only be done with the Leaflet.MapboxVectorTile or the Hoverboard plugin, but neither of those works with Leaflet 1.0.0 (or greater).

    VectorGrid leverages the GridLayer feature introduced in Leaflet 1.0.0. from the first link

    – Bill Chappell Aug 14 '18 at 18:36
  • https://github.com/Leaflet/Leaflet.VectorGrid is the first link – Bill Chappell Aug 14 '18 at 18:37
  • @BillChappell but the documentation stills says that it can only do Mapbox... See: https://github.com/mapbox/vector-tile-js – LBes Aug 14 '18 at 18:38
  • I believe MapBox was one of the first to create vector tiles, you can use their utility to create them without cost. – Bill Chappell Aug 14 '18 at 18:42
  • https://www.mapbox.com/vector-tiles/ it's an open standard. – Bill Chappell Aug 14 '18 at 18:43
  • But I have my tiles from OpenMapTiles... I am quite unsure they follow the same standard... – LBes Aug 14 '18 at 18:45
  • https://github.com/mapbox/awesome-vector-tiles Need to look here.. – Bill Chappell Aug 14 '18 at 18:46
  • @BillChappell I fail to understand how that can help me, this is once again a Mapbox documentation that I cannot use and that I am unsure my tiles downloaded from openmaptiles follow... – LBes Aug 14 '18 at 18:49
  • @BillChappell still having issues with it – LBes Aug 15 '18 at 13:09
  • Hi, tried https://openmaptiles.org/docs/website/leaflet/ and this fails, with the vectorgrid plugin tried this. https://cdn.jsdelivr.net/npm/Leaflet.TileLayer.MBTiles@1.0.0/demo/demo.html and it works with their mbtiles sample data but not openStreetMap tiles.

    Had an issue with mime type, because IIS couldn't see the mbtiles file, set it as application/x-protobuf and it worked for their sample data but not yours. There is some discussion on-line about this, this may be part of the problem.

    – Bill Chappell Aug 15 '18 at 13:23
  • @BillChappell ok I'm continuing this in the chat :) – LBes Aug 15 '18 at 13:28

0 Answers0