-
Notifications
You must be signed in to change notification settings - Fork 410
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
Conversation
c0f1d05
to
85c27cf
Compare
85c27cf
to
a5b2a8b
Compare
@@ -106,23 +106,7 @@ var styleFunction = function(feature) { | |||
|
|||
Layers.registerType('vector', { | |||
create: (options) => { | |||
let features; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
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 inmap/openlayers/Feature.jsx
this.layer
member inmap/openlayers/Layer.jsx
needs to be a state, otherwise the component isn't updated when the actual layer is constructed inthis.addLayer
, leading toconst children = layer ? [...] : null
inrender()
yieldingchildren = null
the very first time the layer component is rendered, because the layer wasn't yet constructed. Unlesslayer
is part of the state, the component won't get refreshed whenlayer
is initialized, meaning that the layer component will only be correctly rendered on the next action which triggers a repaint.