-
Notifications
You must be signed in to change notification settings - Fork 9
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
Set pane in vector feature style to improve ordering #212
Conversation
This improves ordering between layers of type vector/GeoJSON. Multiple GeoJSON layers have features rendered in a shared svg element inside the overlay pane. This amends the styling of features to specify the pane created for the layer. This results in an svg element in each GeoJSON layer pane.
Can you provide instructions for reproducing the problem you are trying to solve? It seems odd to me that setting a |
The problem is that the ordering of GeoJSON layer features doesn't follow the layer ordering. The earlier layer order change improved ordering between layers of different types. Ordering of layers of the same GeoJSON type seemed OK but we later observed it can differ. We recently changed CleanBC's layer of public charging stations from type Esri Feature to GeoJSON and now the order instability is easy to see (https://cleanbcfleet.apps.gov.bc.ca/) - the public charging station is on top when it should be on the bottom. 'pane' is a parameter in both layer options (https://leafletjs.com/reference.html#geojson-option, inherited from Layer) as well as layer path options (https://leafletjs.com/reference.html#path-option, also inherited from Layer: "By default the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default."). Without this change, all GeoJSON features are drawn in the same svg element in the overlay pane: With this change applied, each layer gets its own svg element: So ... I know it looks odd :) but I hope this explains things. I'm happy to demo it for you if you like. |
Thanks for the comments. I can see what you are trying to solve, but why are you passing the |
I think pane is valid - https://leafletjs.com/reference.html#path-option shows pane as one of the path options inherited from Layer. These path options (such as others we use like "fillColor" and "stroke") aren't CSS options - maybe they're part of a vocabulary unique to Leaflet. |
Thanks, I missed expanding the properties derived from the layer options! I still find it confusing that you effectively set the pane twice (once via the style and once in layer options around line 160). Would there be any negative consequence to removing pane from layerOptions line 160? |
There doesn't seem to be any impact when I remove pane from layerOptions. I've tested it in multiple SMK apps including one with multiple layers of supported types and haven't noticed any discrepancies in expected behaviour. I'll remove it. |
This improves ordering between layers of type vector/GeoJSON. Multiple GeoJSON layers have features rendered in a shared svg element inside the overlay pane. This amends the styling of features to specify the pane created for the layer. This results in an svg element in each GeoJSON layer pane.