Skip to content

Commit

Permalink
type hint
Browse files Browse the repository at this point in the history
  • Loading branch information
mortewle committed Nov 27, 2023
1 parent b900541 commit 0a1dc4d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/sgis/maps/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,23 @@ def to_tile(tile: str | xyzservices.TileProvider) -> folium.TileLayer:
"norge_i_bilder": kartverket.norge_i_bilder,
"dark": xyz.CartoDB.DarkMatter,
}
if not isinstance(tile, str):
return folium.TileLayer(tile)

try:
tile = bagrunnskart[tile.lower()]
except KeyError:
tile = xyzservices.providers.query_name(tile)

try:
name = tile["name"]
except TypeError:
name = tile

return folium.TileLayer(tile, name=name)
if not isinstance(tile, str):
try:
return folium.TileLayer(tile, name=name)
except TypeError:
return folium.TileLayer(tile)

try:
provider = bagrunnskart[tile.lower()]
except KeyError:
provider = xyzservices.providers.query_name(tile)

return folium.TileLayer(provider, name=name)


class Explore(Map):
Expand Down

0 comments on commit 0a1dc4d

Please sign in to comment.