(
self,
tiles: Union[str, xyzservices.TileProvider] = "OpenStreetMap",
min_zoom: Optional[int] = None,
max_zoom: Optional[int] = None,
max_native_zoom: Optional[int] = None,
attr: Optional[str] = None,
detect_retina: bool = False,
name: Optional[str] = None,
overlay: bool = False,
control: bool = True,
show: bool = True,
no_wrap: bool = False,
subdomains: str = "abc",
tms: bool = False,
opacity: float = 1,
**kwargs,
)
| 92 | ) |
| 93 | |
| 94 | def __init__( |
| 95 | self, |
| 96 | tiles: Union[str, xyzservices.TileProvider] = "OpenStreetMap", |
| 97 | min_zoom: Optional[int] = None, |
| 98 | max_zoom: Optional[int] = None, |
| 99 | max_native_zoom: Optional[int] = None, |
| 100 | attr: Optional[str] = None, |
| 101 | detect_retina: bool = False, |
| 102 | name: Optional[str] = None, |
| 103 | overlay: bool = False, |
| 104 | control: bool = True, |
| 105 | show: bool = True, |
| 106 | no_wrap: bool = False, |
| 107 | subdomains: str = "abc", |
| 108 | tms: bool = False, |
| 109 | opacity: float = 1, |
| 110 | **kwargs, |
| 111 | ): |
| 112 | if isinstance(tiles, str): |
| 113 | if tiles.lower() == "openstreetmap": |
| 114 | tiles = "OpenStreetMap Mapnik" |
| 115 | if name is None: |
| 116 | name = "openstreetmap" |
| 117 | try: |
| 118 | tiles = xyzservices.providers.query_name(tiles) |
| 119 | except ValueError: |
| 120 | # no match, likely a custom URL |
| 121 | pass |
| 122 | |
| 123 | if isinstance(tiles, xyzservices.TileProvider): |
| 124 | attr = attr if attr else tiles.html_attribution # type: ignore |
| 125 | min_zoom = min_zoom or tiles.get("min_zoom") |
| 126 | max_zoom = max_zoom or tiles.get("max_zoom") |
| 127 | subdomains = tiles.get("subdomains", subdomains) |
| 128 | if name is None: |
| 129 | name = tiles.name.replace(".", "").lower() |
| 130 | tiles = tiles.build_url(fill_subdomain=False, scale_factor="{r}") # type: ignore |
| 131 | |
| 132 | self.tile_name = ( |
| 133 | name if name is not None else "".join(tiles.lower().strip().split()) |
| 134 | ) |
| 135 | super().__init__( |
| 136 | name=self.tile_name, overlay=overlay, control=control, show=show |
| 137 | ) |
| 138 | self._name = "TileLayer" |
| 139 | |
| 140 | self.tiles = tiles |
| 141 | if not attr: |
| 142 | raise ValueError("Custom tiles must have an attribution.") |
| 143 | |
| 144 | self.options = remove_empty( |
| 145 | min_zoom=min_zoom or 0, |
| 146 | max_zoom=max_zoom or 18, |
| 147 | max_native_zoom=max_native_zoom or max_zoom or 18, |
| 148 | no_wrap=no_wrap, |
| 149 | attribution=attr, |
| 150 | subdomains=subdomains, |
| 151 | detect_retina=detect_retina, |
no test coverage detected