3

Loading geojson via ajax in leaflet using bbox and How to add a bounding box filter to this leaflet WFS request? both answer how to request vector layer data within a leaflet map by the map's bounding box. However both answers discard the vector layer's data when refreshing, with no caching of the results. I foresee some kind of merging olddata and newdata arrays while removing duplicates and then redrawing the layer.

I found the leaflet-tilelayer-geojson plugin which creates a leaflet geojson layer from tiles of json, served from a request of URL http://{s}.somedomain.com/blabla/{z}/{x}/{y}.json, but the plugin has not been updated for leaflet 1.0

Is there a commonly accepted method/plugin for caching this data?

raphael
  • 3,407
  • 23
  • 61

1 Answers1

0

From the leaflet plugins page there seem to be 2 current plugins for vector tiles based on the Mapbox spec.

  • geojson-vt which slices the GeoJSON client-side
  • leaflet.VectorGrid which can take an external hosted protobuf source like https://free-{s}.tilehosting.com/data/v3/{z}/{x}/{y}.pbf, otherwise it will use geojson-vt as per above

Mapzen's Tangram is a Leaflet Plugin which also supports GeoJSON vector tile sources. Though the focus seems on style, you can add custom events to feature hover or click

raphael
  • 3,407
  • 23
  • 61