Open ghost opened 8 years ago
Would it be possible to cache the features just as the slicer does?
No, because protobuf tiles don't have features, they only have already sliced & cropped features. Thus, accessing a "feature" in a protobuf vector tile will only return that feature with a partial geometry (the piece that intersects the tile bounds plus the margin buffer).
Implementing some kind of feature-under-pointer feature should be possible, by delegating pointer events from the gridlayer to the tile renderers. That's simply not implemented yet, so feel free to hack away and propose a PR.
Sliced and cropped is fine. I implemented a pick logic that uses the sliced features from geojson-vt tiles. I added runtime info to the feature.tags and called the drawing function again so I can change the styling at runtime without rendering the complete map. Calling the protobuf renderers invokes the fetch process again, doesn't it?
Calling the protobuf renderers invokes the fetch process again, doesn't it?
No, as the tile is an existing instance of L.Renderer
and has internal references to the geometries drawn in it.
How would I access the renderer for a tile with the address {x,y,z} ?
You'll need to modify the code from src/Leaflet.VectorGrid.js
and store the renderers themselves somewhere. Right now only their containers are stored as the grid tiles (see core leaflet's src/layer/tile/GridLayer.js
). Storing the renderers should be possible to be done in a similar fashion, with a key-indexed dictionary, and taking special care to remove references to renderers when tiles are pruned.
Referencing #217
@IvanSanchez You think subbing out the Renderer, you could use something like this? https://github.com/triedeti/Leaflet.streetlabels
Was looking into getting text-label on a vector (ie roads)
Hi, in the geojson-vt variant I'm able to access tile features after the map is rendered, e.g. in a click event handler. I have a scenario where interacting with the map is important, clicking single polygons or selecting groups of polygons in a drawn rectangle or circle. To implement that I need to access the feature geometries and tags contained in the tile. In the protobuf variant all feature info is thrown away after the tile is rendered and I'm not able to access the polygon geometry any more. Would it be possible to cache the features just as the slicer does? Memory constraints won't be any different than with the slicer, would they? -Thomas