question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature.setStyle should be nullable

See original GitHub issue

This 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:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
ahocevarcommented, Jun 11, 2020

#11174 improves the types and docs. @bkuster, you can definitely call feature.setStyle() to unset the style. It is equivalent to feature.setStyle(null) or any falsey value as argument.

0reactions
bkustercommented, Jun 11, 2020

thanks for the fix. would have opened a PR next week, but am sadly crunching at the moment.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found