-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Defines an AbstractDrawControl and implementation for the current draw control features. #1666
Defines an AbstractDrawControl and implementation for the current draw control features. #1666
Conversation
geemap/map_widgets.py
Outdated
@@ -377,3 +380,183 @@ def _objects_info(self, latlon): | |||
nodes.append(tree_node) | |||
|
|||
return self._root_node("Objects", nodes) | |||
|
|||
|
|||
class DrawActions(enum.StrEnum): |
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.
Thanks a lot for your work on this. Some CI tests failed because of enum.StrEnum
, which seems only available in Python 3.11. We need an alternative to support Python 3.8-3.10
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.
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.
Ah, thanks for catching this so quickly, working on a fix now. And I found one other issue related to clear_draw_control
keyword didn't get properly initialized on the reset() function.
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.
The ipyleaflet DrawControl is quite buggy. Here are some issues I am aware of.
- Draw control can't stop drawing after draw more than one shape jupyter-widgets/ipyleaflet#1119
- Draw Control ( circle) jupyter-widgets/ipyleaflet#876
- DrawControl edited event: which shape was edited? jupyter-widgets/ipyleaflet#849
- Select and edit vector data in ipyleaflet jupyter-widgets/ipyleaflet#599
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've amended the last commit to use the normal enum.Enum
, so hopefully the tests will not break there.
1042517
to
7c0d85a
Compare
It looks great! I added some docstrings so that the classes can show up in the documentation. I also fixed a bug in the draw control |
Thank you for the fix! |
AbstractDrawControl
AbstractDrawControl
, which acts an interface between any map's draw control functionality (like ipyleaflet'sDrawControl
) to the user's geemap code.DrawControl
, and the rest of the API takes care of keeping the geometries, feature list, and feature collections in sync for the user to use in their script:MapDrawControl
which extends the ipyleaflet'sDrawControl
so that user's can continue using the draw control API exactly as they have been (I hope).DrawControl
that disallows us to keep the edited geometries in sync with the stored geometries in geemap. Notably, this bug is not present in Colab notebooks, but is present in Jupyter Labs. I have proposed a fix for it in ipyleaflet. After this fix is in, we can consider keeping the geometries in sync with the drawn geometries using ipyleaflet'sDrawControl
data field. Until then, I kept the existing behavior where edited geometries are added instead of modified in place.Unfortunately, I'm not expert at using geemap so I will need your help to figure out if this change won't break existing scripts!