-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add text clipping option on symbol layers #4064
Comments
Hi @pixnlove, This doesn't appear to be a bug or feature request, and unfortunately we don't have the bandwidth to offer support on Github. I suggest you post future questions like this on StackOverflow. |
Thanks for your help @mollymerp. I think it's a feature request but maybe I'm doing something wrong. When I'm adding these two properties, I'm losing some text values and text index behaves badly. My map looks like now: And my layer is now:
Using marker like Roadtrippers is not very powerful with a large dataset, I would like to do the same thing with a symbol layer but you seem to consider the text as an other layer. It will be cool to have a layout property "text-clip-icon". |
@pixnlove I see what you mean. I think this might be a technical limitation of our current implementation of symbol layers – we draw all icons in a layer, and then all text on top of that, so there is no maintained relationship between a single icon and its text label in the render order. |
@mollymerp, do you have some news about this feature request ? |
@pixnlove this is not on our immediate roadmap unfortunately. |
Equivalent issue for native: mapbox/mapbox-gl-native#8235. |
I'll go ahead and upvote this feature. |
For those interested, we also ran into this issue and we "solved" it by generating icons on the fly on a off-screen canvas and using token substitution to match the correct image with the correct point. Roughly what we did is: prices.forEach((price) => {
const imageData = createIcon(price);
map.addImage('house-' + price, imageData);
});
map.addLayer({
layout: {
'icon-name': 'house-{price}'
}
});
|
Oh that's a very interesting approach! Thanks @sjorsrijsdam |
@sjorsrijsdam – I was looking at the API doc for
Then I found this information:
Did you ever encountered that issue, what type of scale do you have experience with? Could you confirm that 1024x1024 is the limit? |
Not sure this limit is actually enforced... I can't spot anything on Map.addImage on Style.addImage nor the ImageManager.addImage 🤔 |
@nrako We never ran into limits of the sprite size. We did have to abandon this idea though because of performance problems on mobile. Every time you would move or zoom the map, Mapbox would need to transfer the icon data of each icon to the WebGL context. That turned out to be a bottle neck. |
@sjorsrijsdam – Thank you for sharing your experience. I'm not totally sure I understand why Mapbox would need to transfer all images data to the WebGL context on all "camera change" – my quick research on that topic was vain. I might just try and inspect that by myself. Could you share what approach you ended up taking? |
Mapbox GL JS does not transfer all images data to the WebGL context on every camera change -- only when a tile is loaded or the image is changed. |
We ended up using just a single image for all items on the map and used a popup to show the price. |
At the moment it turns out that there are 3 possible options (to create behavior as in the image in the first post): Suppose there is a need to create> 400 labels with texts that will be moved on the map in real time. |
One solution to this may be to group these layers in a way that tells the renderer to draw these on a per feature level first. ie. feature A layer 1,2,3 . then render feature B layer 1,2,3, then composite those two. |
This is a ridiculously simple and common use case that I can't believe is not supported. Have people found any practical workarounds for this? |
There seems to be a I've tried it out, drawing an image in the
I guess, given the shader code one could make their own renderer/painter/customlayer for drawing text and icon in a single pass. |
Hi, any news on this feature request? Any possible workaround? |
Sorry, repeating the question: has anyone found reasonable workaround? |
@gotestrand @gitcatrat We ended up generating icons on the fly with #map.event:styleimagemissing as suggested above. Have a look at Map.vue#L258. We did not notice any performance problems, but keep in mind our icons are limited to only around 200 different ones. You can see the result of this at https://kiel-live.github.io/map |
@lukashass Not really an option because |
I don't know if this will work for everyone, but this worked for me. On the bottom you can see a number of the circles do NOT have the text overlay. On the top you can see it is fixed. The way I did it was:
|
Here another version of this here https://bl.ocks.org/stevage/23d881a66e2bcca385d8cc074691b674 |
@julianmlr markers aren't as performant as symbols when you have to draw hundreds of them |
Any updates? MapBox still has this issue, really? |
mapbox-gl-js isn't under an open/permissive license anymore. Any contributions coming from Mapbox will probably align with their business goals. Any other company is probably using the older version that is under a permissive license and changes made to that would be in some public fork. Not sure if it exists. https://github.com/maplibre/maplibre-gl-js This seems to be a fork. And here's the same issue maplibre/maplibre-gl-js#49 The reason why this is still not implemented is because it requires significant nontrivial changes to the shaders that render elements. |
This way, there is absolutely no overlap of multiple clusters! |
Anyone found a solution to this? We're not using clustering and are visualizing several assets on the map. When assets overlap we have issues where the text disappears. We have 2x Layers. 1 layer for the background circles, and 1 layer as a symbol which holds the text. Both layers are set to the same data source. Is there a concept of hierarchy whereby assets stack behind one another if they're overlapping. |
Having the same issue. This is insane that it has been running for the past 7 years... . I hope I'm missing something here. |
@tristan-garaud @elliotclements One possible solution is to use |
@alexshalamov Oh wow, I was sure that I try this approach without success. Did it again with the example and it worked. Don't know what I missed the first time but thanks, it works. |
Thanks Alex! I've been looking for this solution for months. |
@elliotclements Could you elaborate on your approach since it sounds like we have the same issues/requirements with the general layering issue here but also combined with the color? |
@jonashofer You can use SDF |
Thank you all! I'm going to close issue, because |
Hi everybody !
I have a problem with my symbol layer : my text is not hidden by other symbols, how to do like on the second screenshot (screenshot from https://roadtrippers.com who is using Mapbox too)? FYI, my layer looks like :
The text was updated successfully, but these errors were encountered: