Skip to content

Commit

Permalink
Better None checks on properties lookup.
Browse files Browse the repository at this point in the history
  • Loading branch information
sufyanAbbasi committed Aug 19, 2023
1 parent 85e2dd0 commit 1042517
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions geemap/map_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,18 +434,19 @@ def last_feature(self):
def count(self):
return len(self.geometries)

def reset(self, clear_draw_control=True):
def reset(self):
"""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
if clear_draw_control:
self._clear_draw_control()
self._clear_draw_control()

def remove_geometry(self, geometry):
if not geometry:
return
index = self.geometries.index(geometry)
if index >= 0:
del self.geometries[index]
Expand All @@ -459,13 +460,17 @@ def remove_geometry(self, geometry):
self._redraw_layer()

def get_geometry_properties(self, geometry):
if not geometry:
return None
index = self.geometries.index(geometry)
if index >= 0:
return self.properties[index]
else:
return None

def set_geometry_properties(self, geometry, property):
if not geometry:
return
index = self.geometries.index(geometry)
if index >= 0:
self.properties[index] = property
Expand Down

0 comments on commit 1042517

Please sign in to comment.