Skip to content
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

Remove redundant vector layer feature initialization #1206

Closed
wants to merge 1 commit into from

Conversation

manisandro
Copy link
Contributor

@manisandro manisandro commented Oct 25, 2016

  • Transforming and setting the features in map/openlayers/plugins/VectorLayer.js is redundant and leads to features added directly to the openlayers layer which are unmanaged by react: the features are already managed in the wrapper class in map/openlayers/Feature.jsx
  • The this.layer member in map/openlayers/Layer.jsx needs to be a state, otherwise the component isn't updated when the actual layer is constructed in this.addLayer, leading to const children = layer ? [...] : null in render() yielding children = null the very first time the layer component is rendered, because the layer wasn't yet constructed. Unless layer is part of the state, the component won't get refreshed when layer is initialized, meaning that the layer component will only be correctly rendered on the next action which triggers a repaint.

@simboss simboss added the ready label Oct 25, 2016
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) to 79.936% when pulling c0f1d05 on sourcepole:vectorfeatures into f0fba60 on geosolutions-it:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 80.123% when pulling 85c27cf on sourcepole:vectorfeatures into f0fba60 on geosolutions-it:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 79.893% when pulling a5b2a8b on sourcepole:vectorfeatures into baaa7d4 on geosolutions-it:master.

@@ -106,23 +106,7 @@ var styleFunction = function(feature) {

Layers.registerType('vector', {
create: (options) => {
let features;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to allow configuring the layer via JSON instead of using Feature.jsx components

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uhm, there needs to be a way to suppress this though, since when adding a vector layer to the layers state, Feature.jsx objects are created automatically. This leads to those Feature.jsx objects being correctly managed whereas those added directly are unmanaged, meaning they are not removed anymore when changing the layer properties (i.e. changing the features field) without removing and re-adding the layer. I don't know the JSON use-case, do you see a solution?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to do some testing, I will let you know...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbarto Did you manage to have a look at this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be fixed by this commit, using forceUpdate.
d33e1f8#diff-b2a987f6d21da3daede77b61016d2380R129

Can you confirm?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I still end up with unmanaged features using latest master.

@offtherailz offtherailz changed the title Remove redundant vector layer feature inditialization Remove redundant vector layer feature initialization Nov 30, 2016
@mbarto
Copy link
Contributor

mbarto commented May 11, 2017

Fixed the openlayers plugin with #1793, pending review of leaflet: #1794

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants