Render MVTLayer using TextLayer
See original GitHub issueDescription
I’ve been using MVTLayer with the default renderSubLayers
and it works perfectly. Aside that, I’ve created a layer that extends from CompositeLayer to show a TextLayer above the GeoJsonLayer following this deck.gl tutorial. It works but it repeats the TextLayer inside each geometry.
Repro Steps
I’ve made an example that reproduces the problem.
As you can see in this screenshot, the word Illinois
is repeated four times inside the state polygon.
Environment
- Framework Version: deck.gl 8.1.1
- Browser Version: Chrome 80.0.3987.163
- OS: macOS 10.14.6
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Render MVTLayer using TextLayer · Issue #4469 · visgl/deck.gl
I've been using MVTLayer with the default renderSubLayers and it works perfectly. Aside that, I've created a layer that extends from ...
Read more >Deck Gl Mvt Textlayer - StackBlitz
Example deck.gl project rendering MVTLayer using GeoJsonLayer and TextLayer. ... import {MVTLayer} from '@deck.gl/geo-layers';.
Read more >MVTLayer - deck.gl
The MVTLayer is a derived TileLayer that makes it possible to visualize very large datasets through MVTs (Mapbox Vector Tiles). Behaving like TileLayer...
Read more >deck.gl | TextLayer
TextLayer. The text layer renders text labels on the map using texture mapping. This Layer is extended based on Icon Layer and wrapped...
Read more >Sample implementation of `getRenderedFeatures` in Deck.gl ...
Render the MVTLayer; Listen onViewStateChange from the deck instance with some debounce; Then call getRenderedFeatures. Something like: function ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, I think the
icon-cluster-layer
is actually a good reference point. You’ll have to play around with it a bit. For example you can see that theMVTLayer
currently subclasses theTileLayer
I believe. So you might have to copy some code from theMVTLayer
so that you can render both geometry layers and aTextLayer
.Along the same lines, a Text/Symbol layer that handles symbol collisions is of interest to me personally. It might be out of scope for the main Deck.gl repository, since Deck.gl isn’t in the game of creating a basemap, but it could be a separate open source repo. I’ve started reading through relevant code in Mapbox GL JS, but haven’t gotten around to extracting it for an implementation that might work with Deck.gl.
Currently there’s no merging that happens in the MVTLayer client side. This would be non-trivial since the number of tiles necessary to merge a polygon is unknown before retrieving the tiles.
Personally, I think you’d have much better luck pre-generating anchor points for text labels and storing them as a point layer in the MVT, so that you aren’t finding points client side.
I don’t think polygon merging was ever implemented, but it was discussed here: https://github.com/uber/deck.gl/pull/3704#issuecomment-535613783
Hello, I’m interested in this too. Are you saying is posible to subclass
MVTLayer
to create an “adaptor layer” like in the icon-cluster example or the labeled-geosjon example ??Polygon data will still be split into multiple tiles, so can we merge them back at the client-side to find the anchor point of the labels or should we change the part that does the MVT generation ?
I think previous versions of the
MVTLayer
did this client-side polygon merging but stopped it because it was not the best alternative, so it is okay to do it here ?