How to use the ipyleaflet.leaflet.LayerException function in ipyleaflet

To help you get started, we’ve selected a few ipyleaflet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jupyter-widgets / ipyleaflet / ipyleaflet / leaflet.py View on Github external
def substitute_layer(self, old, new):
        if isinstance(new, dict):
            new = basemap_to_tiles(new)
        if old.model_id not in self._layer_ids:
            raise LayerException('Could not substitute layer: layer not in layergroup.')
        self.layers = tuple([new if l.model_id == old.model_id else l for l in self.layers])
github jupyter-widgets / ipyleaflet / ipyleaflet / leaflet.py View on Github external
def _validate_layers(self, proposal):
        '''Validate layers list.

        Makes sure only one instance of any given layer can exist in the
        layers list.
        '''
        self._layer_ids = [l.model_id for l in proposal.value]
        if len(set(self._layer_ids)) != len(self._layer_ids):
            raise LayerException('duplicate layer detected, only use each layer once')
        return proposal.value
github jupyter-widgets / ipyleaflet / ipyleaflet / leaflet.py View on Github external
def remove_layer(self, layer):
        if layer.model_id not in self._layer_ids:
            raise LayerException('layer not on in layergroup: %r' % layer)
        self.layers = tuple([l for l in self.layers if l.model_id != layer.model_id])
github jupyter-widgets / ipyleaflet / ipyleaflet / leaflet.py View on Github external
def substitute_layer(self, old, new):
        if isinstance(new, dict):
            new = basemap_to_tiles(new)
        if old.model_id not in self._layer_ids:
            raise LayerException('Could not substitute layer: layer not on map.')
        self.layers = tuple([new if l.model_id == old.model_id else l for l in self.layers])
github jupyter-widgets / ipyleaflet / ipyleaflet / leaflet.py View on Github external
def add_layer(self, layer):
        if isinstance(layer, dict):
            layer = basemap_to_tiles(layer)
        if layer.model_id in self._layer_ids:
            raise LayerException('layer already on map: %r' % layer)
        self.layers = tuple([l for l in self.layers] + [layer])
github jupyter-widgets / ipyleaflet / ipyleaflet / leaflet.py View on Github external
def remove_layer(self, layer):
        if layer.model_id not in self._layer_ids:
            raise LayerException('layer not on map: %r' % layer)
        self.layers = tuple([l for l in self.layers if l.model_id != layer.model_id])