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
Now if remove the map and then add the same image using the code below it throws an error below. However if you run the last line again Map.addLayer(image, img_params, 'Satellite Image',True) it adds the image to the map. I think there may be bug in remove_layer function.
for layer in Map.layers:
if layer.name == 'Satellite Image':
Map.remove_layer(layer)
Map.addLayer(image, img_params, 'Satellite Image',True)
/usr/local/lib/python3.10/dist-packages/ipyleaflet/leaflet.py in remove(self, item)
2682 """
2683 if isinstance(item, Layer):
-> 2684 if item.model_id not in self._layer_ids:
2685 raise LayerException('layer not on map: %r' % item)
2686 self.layers = tuple([layer for layer in self.layers if layer.model_id != item.model_id])
/usr/local/lib/python3.10/dist-packages/ipywidgets/widgets/widget.py in model_id(self)
518
519 If a Comm doesn't exist yet, a Comm will be created automagically."""
--> 520 return self.comm.comm_id
521
522 #-------------------------------------------------------------------------
AttributeError: 'NoneType' object has no attribute 'comm_id'
The text was updated successfully, but these errors were encountered:
Hi,
Many thanks for solving the other bug with the drawing feature. I have now come across another bug which has appeared from the recent updates.
set up the map
Now if remove the map and then add the same image using the code below it throws an error below. However if you run the last line again
Map.addLayer(image, img_params, 'Satellite Image',True)
it adds the image to the map. I think there may be bug in remove_layer function.Error
AttributeError Traceback (most recent call last)
in <cell line: 4>()
2 if layer.name == 'Satellite Image':
3 Map.remove_layer(layer)
----> 4 Map.addLayer(image, img_params, 'Satellite Image',True)
5 Map.addLayer(image, img_params, 'Satellite Image',True)
6 frames
/usr/local/lib/python3.10/dist-packages/geemap/geemap.py in add_ee_layer(self, ee_object, vis_params, name, shown, opacity)
337 )
338
--> 339 super().add_layer(ee_object, vis_params, name, shown, opacity)
340
341 if isinstance(ee_object, (ee.Image, ee.ImageCollection)):
/usr/local/lib/python3.10/dist-packages/geemap/core.py in add_layer(self, ee_object, vis_params, name, shown, opacity)
754
755 # Remove the layer if it already exists.
--> 756 self.remove(name)
757
758 self.ee_layers[name] = {
/usr/local/lib/python3.10/dist-packages/geemap/core.py in remove(self, widget)
719 tile_layer = ee_layer.get("ee_layer", None)
720 if tile_layer is not None:
--> 721 self.remove_layer(tile_layer)
722 if legend := ee_layer.get("legend", None):
723 self.remove(legend)
/usr/local/lib/python3.10/dist-packages/ipyleaflet/leaflet.py in remove_layer(self, rm_layer)
2539 warnings.warn("remove_layer is deprecated, use remove instead", DeprecationWarning)
2540
-> 2541 self.remove(rm_layer)
2542
2543 def substitute_layer(self, old, new):
/usr/local/lib/python3.10/dist-packages/geemap/core.py in remove(self, widget)
726 return
727
--> 728 super().remove(widget)
729 if isinstance(widget, ipywidgets.Widget):
730 widget.close()
/usr/local/lib/python3.10/dist-packages/ipyleaflet/leaflet.py in remove(self, item)
2682 """
2683 if isinstance(item, Layer):
-> 2684 if item.model_id not in self._layer_ids:
2685 raise LayerException('layer not on map: %r' % item)
2686 self.layers = tuple([layer for layer in self.layers if layer.model_id != item.model_id])
/usr/local/lib/python3.10/dist-packages/ipywidgets/widgets/widget.py in model_id(self)
518
519 If a Comm doesn't exist yet, a Comm will be created automagically."""
--> 520 return self.comm.comm_id
521
522 #-------------------------------------------------------------------------
AttributeError: 'NoneType' object has no attribute 'comm_id'
The text was updated successfully, but these errors were encountered: