Adds a VectorTileLayer to the map. It wraps the ipyleaflet.VectorTileLayer class. See https://ipyleaflet.readthedocs.io/en/latest/layers/vector_tile.html Args: url (str, optional): The URL of the tile layer styles (dict,optional): Style dict, specific to
(
self,
url,
styles: Optional[dict] = {},
layer_name: Optional[str] = "Vector Tile",
**kwargs,
)
| 617 | raise Exception(e) |
| 618 | |
| 619 | def add_vector_tile( |
| 620 | self, |
| 621 | url, |
| 622 | styles: Optional[dict] = {}, |
| 623 | layer_name: Optional[str] = "Vector Tile", |
| 624 | **kwargs, |
| 625 | ) -> None: |
| 626 | """Adds a VectorTileLayer to the map. It wraps the ipyleaflet.VectorTileLayer class. See |
| 627 | https://ipyleaflet.readthedocs.io/en/latest/layers/vector_tile.html |
| 628 | |
| 629 | Args: |
| 630 | url (str, optional): The URL of the tile layer |
| 631 | styles (dict,optional): Style dict, specific to the vector tile source. |
| 632 | layer_name (str, optional): The layer name to use for the layer. Defaults to 'Vector Tile'. |
| 633 | kwargs: Additional keyword arguments to pass to the ipyleaflet.VectorTileLayer class. |
| 634 | """ |
| 635 | if "vector_tile_layer_styles" in kwargs: |
| 636 | styles = kwargs["vector_tile_layer_styles"] |
| 637 | del kwargs["vector_tile_layer_styles"] |
| 638 | try: |
| 639 | vector_tile_layer = ipyleaflet.VectorTileLayer( |
| 640 | url=url, |
| 641 | vector_tile_layer_styles=styles, |
| 642 | **kwargs, |
| 643 | ) |
| 644 | vector_tile_layer.name = layer_name |
| 645 | self.add(vector_tile_layer) |
| 646 | |
| 647 | except Exception as e: |
| 648 | print("Failed to add the specified VectorTileLayer.") |
| 649 | raise Exception(e) |
| 650 | |
| 651 | add_vector_tile_layer = add_vector_tile |
| 652 |