-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Is there a z-index like property? #7016
Comments
Currently there's no such property, and the draw order fully depends on the layer order. We're looking into introducing a z-index-like property as a part of #4225, but that will take a while to get implemented. |
possibly a duplicate of #1349 |
@mourner Using the same vector tile as the source, I see a reversed rendering order when using a circle layer versus a symbol layer. Does that make sense or would you expect them to be the same? In my case, I have time sequential data and there may be two markers with different timestamps at the same location. The circle layer shows the newest marker on top while the symbol layer shows the oldest on top. When clicking on each layer, Edit: I realize now the original question was in regards to layer order., whereas my comment is about feature order within a layer. |
@areichman not sure — maybe @ChrisLoer can chime in on this. |
Hi @areichman, I believe the difference you're seeing between circle layers and symbol layers is because we sort the rendering order of symbol features within a layer based on their y-position: #470. The idea there is that when you have a lot of overlapping icons, consistently sorting them based on y-position makes them look less "jumbled". #4361 (#1349 mentioned by @andrewharvey is another duplicate) proposes adding explicit sort order control, which I think would be the best way to address this. But for some purposes it might make sense to just turn off the y-position sorting for symbol layers (when you're providing the data for the symbol layer and you control the order of the data to match your desired render order). |
How can I add data for order and how to use those for render order? Okay, first, I set order value in fields in tilejson, then what should I do or How the library detects it? is there a reserved keyword for render order? |
@cs09g Setting the |
@ryanhamley There's no order of data. |
If your source is a |
Hi guys, Maybe there is some new API I am not aware of or some tips on how to manage order. Will appreciate an update on this topic. |
@kukiel I usually create some dummy GeoJSON layers and then reference them using the e.g. map.addSource('empty', {
type: 'geojson',
data: { type: 'FeatureCollection', features: [] }
});
const zIndex2 = map.addLayer({
id: 'z-index-2',
type: 'symbol',
source: 'empty'
});
const zIndex1 = map.addLayer({
id: 'z-index-1',
type: 'symbol',
source: 'empty'
}, 'z-index-2'); // place this layer below zIndex2
const polygons = map.addLayer({
id: 'my-polygons',
type: 'symbol',
source: myPolygons
}, 'z-index-1'); // place the polygons on the bottom
const points = map.addLayer({
id: 'my-real-points',
type: 'symbol',
source: myPoints
}, 'z-index-2'); // place the points above the polygons Edit: I do this when I have lots of different layers that may be toggled on/off, so the dummy layers give me something I can always refer to. In the example above, if |
@areichman thanks for sharing, I was actually thinking of something similar but was also hoping maybe there is/will be something built-in. |
For my use case - where I have a known number of possible GeoJSON layers that can appear in a known order - I ended up just always rendering the sources and layers, but passing in an empty but valid GeoJSON object when I want to hide the layers. It remains to be seen how reliable this is. {
type: "FeatureCollection",
features: [],
} |
Building upon @areichman 's answer, I did this (it's in Flutter):
It can then be used like this:
|
mapbox-gl-js version: 0.45.0
Question
Is there a z-index like property for layers?
I had one big geojson vector layer, which I had to split based on its gender property because it was to big and the zoom extent from which it was visible wasn't enough. But because it has many points, depending which layer comes lasts, it overlaps on the other one. In some case this is needed, but in my particular case, I need them to be at the same z-index (let's use this css property for now).
Is there a property for layers that does this, because I couldn't find it in the docs? If not, have you think of implementing this feature? I am pretty sure mapbox users would be very happy to have this feature.
The text was updated successfully, but these errors were encountered: