question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Render MVTLayer using TextLayer

See original GitHub issue

Description

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:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kylebarroncommented, Apr 11, 2020

Are you saying is posible to subclass MVTLayer to create an “adaptor layer”

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 the MVTLayer currently subclasses the TileLayer I believe. So you might have to copy some code from the MVTLayer so that you can render both geometry layers and a TextLayer.

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.

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 ?

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 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 ?

I don’t think polygon merging was ever implemented, but it was discussed here: https://github.com/uber/deck.gl/pull/3704#issuecomment-535613783

1reaction
juandjaracommented, Apr 11, 2020

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 ?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found