1
votes

Background:

  • Leaflet map
  • a vector tile layer
    • MapBox Studio to generate vector tiles (protocol buffer format)
    • MapBox.com for tile hosting
    • using Leaflet.MapboxVectorTile plugin to parse and render MapBox vector tiles

Issues:

  • Cannot get original feature geometry: I wanted to fetch feature geometry so can zoom to it e.g. when user clicks at it. But this plugin (Leaflet.MapboxVectorTile) doesn't have a clear way to do so. The geom values (including BBOX) are all in relative coordinates (i.e., not the original geometry)

  • Poor capability in identifying feature (click/hover): Another problem with this plugin is its identification algorithm is not robust enough. The authors disabled hover-identify as it turns out to be very slow. For clicking, I noticed sometimes it's hard to select a polygon (happens for some polygons and depends on where you clicked within the polygon), you have to click at certain locations so the plugin is able to identify the feature.

This plugin is very good in my experience except for above two issues.

My Questions:

  • Is there a counterpart MapBox solution that does the similar thing to this plugin? In other words, to parse and render a vector tile layer service on map, with support in robust feature identifying and ability to fetch feature geometry?
  • Currently the tiles generated in MapBox studio is in .pbf which is great in terms of efficient data transmission. I wonder if it supports JSON format (GeoJSON or TopoJSON) out of box? If it does, I probably could try using MapBox.JS featureLayer to consume vector tile json data.
  • I understand MapBOX GL.js is designed for vector tile based maps. I am looking for adding a vector tile layer though.

appreciate any response. thanks!

1

1 Answers

3
votes

You'll want to try out mapbox-gl-leaflet, a library that integrates the efficient Mapbox GL library into Leaflet as a layer.

Cannot get original feature geometry

Vector tiles do not contain the original feature geometry. Mapbox GL does provide an api that delivers GeoJSON, but it isn't going to be your raw data: if it was, then the map would be slow and inefficient, since raw data is over-detailed.