-
Notifications
You must be signed in to change notification settings - Fork 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
Per-feature z-index #5216
Comments
There is no concept of "z-index" in deck.gl. In instanced rendering, the features are drawn in parallel, instead of a sequential order. It is possible to add a small depth shift to each geometry to achieve that effect, however it may interfere with the actual 3d depth. We are unlikely able to add this as a generic feature. It will have to be applied on a case-by-case bases. |
Thank you for your answer, I can see how that might be a problem. |
You can add the small z shift in most layers' new MVTLayer({
...
renderSubLayers: props => new ScatterplotLayer({
getPosition: (f, {index}) => f.geometry.coordinates.concat(index * 0.001),
...
});
}); |
For documentation purposes in case somebody wants to do the same using an MVT layer and arrives here. The following code works: new MVTLayer({
...
renderSubLayers: (props) => {
return new ScatterplotLayer({
...props,
getPosition: (f, index): => {
const z = index * 0.01
return [
...f.geometry.coordinates,
z
]
}
})
}
} Notice that, as we are passing the props from the MVTLayer to the ScatterplotLayer, it inherits the modelview matrix and the coordinate system origin and we can use the data fetched by the MVT layer as is. If, otherwise, we don't pass the MVTLayer props to the ScatterplotLayer, we will need to convert the MVT data coordinates to world coordinates. |
Hello All, Happy to have found this example. However, I am using a GeoJsonLayer which does not have the accessor Thanks in advance! Amanda |
@amandakoster you can try getpolygonoffset to offset complete layer along the z-axis. It's a base layer property, so should solve your case too |
@amandakoster what worked for me in my |
@jzzfs @Anand2489 @Pessimistress I have an Any ideas of how to rectify this? |
@chriszrc I suppose you'll have to split the layers into circles & text. |
@jzzfs I originally did split the layers, but then the labels are still on top of everything :( |
@jzzfs can you give an example of how you sorted the data in the GeoJsonLayer? |
@tomeronen sure: const data = [...];
const sortByLineMembers = () => {
return data.features
.slice()
.sort((f1, f2) =>
isLineNameSimilar(f1.properties.name) ||
isLineNameSimilar(f2.properties.name)
? 1
: -1
);
};
const lines = new GeoJsonLayer({
id: 'subway-lines-layer',
data: sortByLineMembers(),
pickable: true,
...
}); Shameless plug: this is taken from my Google Maps Handbook. |
@chriszrc did you manage to fix the issue? I have the same problem. |
@gabrielmilitaruwebmarc nope 😥 |
@chriszrc I'm wondering the same thing, been trying to figure this out for several months now. I found this older thread: #5672 Apparently setting a text-background, or setting a "z" position on the text position array worked, but I have not been successful when trying either. Have you found anything new? |
Target Use case
When dealing with a single layer with multiple features (like points in an MVT for example), you might want to draw some of those features on top of others interactively
Proposed feature
Have a getZIndex or similar function that can be defined per feature similar to how getRadius or getFillColor are implemented in some layers
To Do List
The text was updated successfully, but these errors were encountered: