You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now I'm not sure if there is an easy way to determine if any of the edit interactions are currently "active". This would be useful when adding custom behaviors that should/should not do certain things when a user is using interactions from the edit control, like drawing on the map.
An interaction object is added to instance.edit the first time it is turned on, but is never removed. This can be used to see if an interaction has been used by looking on the instance.edit control eg: instance.edit.drawInteraction or instance.edit.modifyInteraction, but because it is never removed, it cannot be used to determine if the interaction is "active".
Interestingly, interaction objects do have a getActive() method, but our edit control does not use this: https://openlayers.org/en/latest/apidoc/module-ol_interaction_Interaction-Interaction.html#getActive Instead of making the interaction "inactive" it removes the interaction from the map, but keeps the interaction object itself at instance.edit.*. The interaction object continues to report getActive() == true even after the interaction was removed from the map.
After a quick look at this I see two possible approaches:
Remove the interaction object from instance.edit after removing the interaction from the map. This way the presence of the interaction object can be used to determine if it is active.
Finally, it would be nice if the edit control provided some helper methods to determine if any part of the edit control "is active". This could be a convenience method wrapped around one of the approaches described above. For example:
I feel that we should follow the patterns that OpenLayers has established and keep farmOS-map's behavior as unsurprising as possible when OL functionality is used programmatically.
In practice I think that means you're highlighting some real issues here @paul121.
IMHO we should;
Call interaction.setActive(false)and set instance.edit.drawInteraction to null when finishing/cancelling drawing
Observe the interaction's active property and honor programmatic changes to it
Probably provide some sort of convenience method(s) like you're describing
Right now I'm not sure if there is an easy way to determine if any of the edit interactions are currently "active". This would be useful when adding custom behaviors that should/should not do certain things when a user is using interactions from the edit control, like drawing on the map.
An interaction object is added to
instance.edit
the first time it is turned on, but is never removed. This can be used to see if an interaction has been used by looking on theinstance.edit
control eg:instance.edit.drawInteraction
orinstance.edit.modifyInteraction
, but because it is never removed, it cannot be used to determine if the interaction is "active".Interestingly, interaction objects do have a
getActive()
method, but our edit control does not use this: https://openlayers.org/en/latest/apidoc/module-ol_interaction_Interaction-Interaction.html#getActive Instead of making the interaction "inactive" it removes the interaction from the map, but keeps the interaction object itself atinstance.edit.*
. The interaction object continues to reportgetActive() == true
even after the interaction was removed from the map.After a quick look at this I see two possible approaches:
Remove the interaction object from
instance.edit
after removing the interaction from the map. This way the presence of the interaction object can be used to determine if it is active.farmOS-map/src/control/Edit/Edit.js
Lines 423 to 444 in 65f13b2
Refactor the edit control to use the "active" state of interactions instead of adding/removing interactions from the map. At first glance it seems like this might be feasible, but I'm not 100% sure. See also Edit interactions remain selected after programatically disabling active state #183
Finally, it would be nice if the edit control provided some helper methods to determine if any part of the edit control "is active". This could be a convenience method wrapped around one of the approaches described above. For example:
The text was updated successfully, but these errors were encountered: