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.

Unexpected behaviour in v6.0.1 - Feature.getStyle()

See original GitHub issue

Describe the bug In version 5.3.0 Feature.getStyle() returned an object, in version 6.0.1 it’s now returning a function.

To Reproduce Steps to reproduce the behavior:

  1. Create a Feature and render it on the map.
  2. Get the feature using VectorSource.getFeatureById().
  3. Try to extract the style from the feature using Feature.getStyle().

Expected behavior Previously it returned an object upon which I could call setImage() for instance.

More information After debugging some more it appeares it returnes a function that is stored in the variable style_ on the feature object. This function seams to be a static function that expects a feature as it’s parameter. When using that function and passing on the feature as a parameter i get an array of style objects back. In my case it only has one style on position 0. Something like this: const style = feature.getStyle()(feature)[0] Or more readable:

const getStyleFunction = feature.getStyle();  
const stylesArray = getStyleFunction(feature);  
const style = styleArray[0];

Instead of previously: const style = feature.getStyle()

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
mike-000commented, Oct 17, 2019

ol/interaction/Select does test if (this.style_) { but it is meaningless because the initialisation

this.style_ = options.style ? options.style : getDefaultStyleFunction();

should be

this.style_ = options.style !== undefined ? options.style : getDefaultStyleFunction();

null or false could then be specified to prevent overriding the style

1reaction
mike-000commented, Oct 17, 2019

The above would still need to be documented. Previously a Select style only overrode a layer style. If the feature already had a style that had precedence. Backward compatibility could be maintained if the Select only sets its style on a selected feature if the feature has no style, and resets it to undefined when a feature is deselected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

@material-ui/icons | Yarn - Package Manager
This package provides the Google Material icons packaged as a set of React components. Installation. Install the package in your project directory with:...
Read more >
Web Libraries in Jars - WebJars
Angular Hint, org.webjars, angular-hint, 0.1.0 ... app-localize-behavior, org.webjars.bower ... feature.js, org.webjars.bower, feature.js, 1.0.1.
Read more >
office-ui-fabric-react - UNPKG
__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n ... which may lead to unexpected behavior if it differs from the defaults.
Read more >
Overview - Joe Sandbox
Replication Through Removable Media, Service Execution, Port Monitors, Accessibility Features, Process Injection1, Network Sniffing, Application Window ...
Read more >
Overview (Apache Juneau 9.0.0)
JsonSerializer serializer = JsonSerializer . create () .simple() ... One important feature of the bean context API is the ability to wrap Java...
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