I am currently researching different approaches for integrating vector tiles (especially MVT and/or GeoJSON tiles, served from GeoServer) with OpenLayers (^4.0.0) in a manner that would retain access to original vector feature attribute data and interactions therewith. Since there's potentially a lot of vector data to interact with, vector tiles would be highly preferred over raw GeoJSON due to rendering performance (of course TopoJSON might be an alternative to all this).

Interaction with standard OpenLayers API MVT integration is possible pixelwise with forEachFeatureAtPixel. However, due to the nature of vector tiles, it seems not possible out-of-the-box to access the "original" feature data behind e.g. MVT. with OL methods.

Following approaches have been suggested for accessing data:

1) Using Mapbox's vector-tile library https://github.com/mapbox/vector-tile-js

2) Loading features in GeoJSON and converting client-side to vector tiles for rendering with: https://github.com/mapbox/geojson-vt

At least to my knowledge, OpenLayers already incorporates some parts of vector-tile-js, but it's stayed unclear to me to which extent and in which methods.

I've compared OpenLayers with Mapbox GL JS's, the latter of which seems to have figured out interaction with rendered vector tiles and original data, for instance in this example: https://www.mapbox.com/mapbox-gl-js/example/query-similar-features/

Digging deeper into the Mapbox GL JS API, it seems that Mapbox uses two different data query methods, map.querySourceFeatures and map.queryRenderedFeatures. Looking into Mapbox GL JS source, this seems to have been somehow managed via maintaining both a cached original data and vector tiles. https://github.com/mapbox/mapbox-gl-js/blob/master/src/source/query_features.js

My real question here is, is there a similar (built-in) approach in OpenLayers, that would allow me to access both "raw" and "rendered" vector tile data, or perhaps using geojson-vt or vector-tile-js to switch between the two? For instance in the manner that would allow one to use methods akin OL's Vector method "getFeaturesInExtent"? i.e. figure out which vector tiles are in View, query corresponding "raw" data and pass on (all) accompanying feature attribute data.

  • I dare that there are no built in methods in Openlayers to filter features like mapbox-gl does with it's map.querySourceFeatures(). The workaround I use is to redraw features calling change() on the source and than filter features by certain criteria in the vector layer style function. – geraldo Jan 8 at 21:14

Your Answer


Browse other questions tagged or ask your own question.