Skip to content

Commit

Permalink
Consolidate reset functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
sufyanAbbasi committed Aug 19, 2023
1 parent b2857c8 commit 85e2dd0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions geemap/geemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ def handle_draw(_, action, geo_json):
self._roi_end = True
self._roi_start = False
except Exception as e:
self.geometries = []
self.properties = []
self.last_geometry = None
self.reset(clear_draw_control=False)
self._roi_start = False
self._roi_end = False
print("There was an error creating Earth Engine Feature.")
Expand Down
5 changes: 3 additions & 2 deletions geemap/map_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,16 @@ def last_feature(self):
def count(self):
return len(self.geometries)

def reset(self):
def reset(self, clear_draw_control=True):
"""Resets the draw controls."""
if self.layer is not None:
self.host_map.remove_layer(self.layer)
self.geometries = []
self.properties = []
self.last_geometry = None
self.layer = None
self._clear_draw_control()
if clear_draw_control:
self._clear_draw_control()

def remove_geometry(self, geometry):
index = self.geometries.index(geometry)
Expand Down

0 comments on commit 85e2dd0

Please sign in to comment.