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
Inconsistent passing of options in L.geoJSON() #6858
Comments
Hi and thank you for the detailed bug report! Hum I can see the use case and simple fix indeed. So the idea is to mimick the behaviour of "custom" options of path/vector layers for point type features, namely for the default created Marker. Now I am concerned about the breaking change possibly affecting existing apps. L.geoJSON(pointFeature, {
opacity: 0.5 // Initially intended for path layers stroke opacity
}); Currently the created Marker is standard. Then there is also a "hole" left for |
@ghybs regarding Yes, the current workaround is to just use But your mentioned breaking change is definitely a problem I haven't seen yet 🤔. Although in your example, as a user, I would expect the Markers have .5 opacity and consider the fact that it's ignored a bug. Are you aware that devs actually rely on that as a feature? I have not seen this mentioned in the documentation. If this was an intentioned feature: it would be a breaking change But I can see there is room for interpretation here 😅 . Do you think an (ugly) additional option like |
Hi, Yeah unfortunately there is a lot of room for interpretation (classic "it is not a bug, it is a (undocumented) feature")... To stay safe, and even though it may look ugly at first, I think your proposed Let's do this. |
to make default Marker (built for "Point" type Geometries) now inherit from the options of the GeoJSON Layer Group, as is already the case for Path-based (vector) Layers. Opt-in feature to avoid changing the default behaviour. See Leaflet#6858 for more details.
to make default Marker (built for "Point" type Geometries) now inherit from the options of the GeoJSON Layer Group, as is already the case for Path-based (vector) Layers. Opt-in feature to avoid changing the default behaviour. See Leaflet#6858 for more details.
Steps to reproduce
Steps to reproduce the behavior:
L.geoJSON()
and pass any options to itExpected behavior
Passing options to
L.geoJSON()
should pass those options to all child elements. This is especially important for plugin authors that use initHooks on leaflet classes.Current behavior
Take a look at the console in this JSFiddle to see that the passed option
testOption: true
is not present for Markers:https://jsfiddle.net/naw79csr/
Environment
Additional context
We found the problem through a bug report in Leaflet-Geoman geoman-io/leaflet-geoman#508
As a test, I've passed the
options
parameter in the leaflet source tonew L.Marker
hereLeaflet/src/layer/GeoJSON.js
Line 184 in 16c49cc
Leaflet/src/layer/GeoJSON.js
Line 189 in 16c49cc
Minimal example reproducing the issue
https://jsfiddle.net/naw79csr/
As always, thank you for leaflet and your outstanding work 👏
The text was updated successfully, but these errors were encountered: