Feature.setStyle should be nullable
See original GitHub issueThis is a documentation bug.
The doclet for ol/Feature#setStyle
reads @param {import("./style/Style.js").StyleLike} style
.
But the documentation cleary states to pass null
for unsetting the style (I personaly like to omit the style, so call feature.setStyle();
). Either way: the docs should allow the style to be nullable or optional or both. I will make a PR for this if you like, just need to figure out which design you guys like setStyle(null)
or setStyle()
or either.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Cannot set a style for clicked features in vector layer
Solution 1: setStyle(null) OpenLayers will use the feature's style if it has one, and otherwise use the layer's style. So re-setting the ...
Read more >ol.Feature#setStyle fails if it passed null or undefined #2725
ol.Feature#setStyle fails if it passed null or undefined. It is a bug. It means that it is not possible to unset a style...
Read more >Openlayers - Unable to set the style of features
I have both tried feature.style = selected_polygon_style; and feature.setStyle(selected_polygon_style); . The first just doesn't change the ...
Read more >Data | Maps JavaScript API - Google Developers
Renders the features on the specified map. If map is set to null , the features will be removed from the map. setStyle....
Read more >ol.Feature - OpenLayers 3 API Reference
Features can be styled individually with setStyle ; otherwise they use the style of their vector ... If it is null the feature...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
#11174 improves the types and docs. @bkuster, you can definitely call
feature.setStyle()
to unset the style. It is equivalent tofeature.setStyle(null)
or any falsey value as argument.thanks for the fix. would have opened a PR next week, but am sadly crunching at the moment.