diff --git a/geoviews/element/geo.py b/geoviews/element/geo.py index 29158a7b..6284ccc5 100644 --- a/geoviews/element/geo.py +++ b/geoviews/element/geo.py @@ -1,6 +1,7 @@ +import sys + import numpy as np import param -from bokeh.models import MercatorTileSource from cartopy import crs as ccrs from cartopy.feature import Feature as cFeature from cartopy.io.img_tiles import GoogleTiles @@ -80,6 +81,12 @@ class HvImageStack: ... geographic_types = (GoogleTiles, cFeature, BaseGeometry) +def _check_bokeh_mercator(data) -> bool: + if "bokeh.models" in sys.modules: + from bokeh.models import MercatorTileSource + return isinstance(data, MercatorTileSource) + return False + def is_geographic(element, kdims=None): """ Utility to determine whether the supplied element optionally @@ -267,8 +274,7 @@ class WMTS(_GeoFeature): layer = param.String(doc="The layer on the tile service") def __init__(self, data, kdims=None, vdims=None, **params): - if ((MercatorTileSource and isinstance(data, MercatorTileSource)) or - (GoogleTiles and isinstance(data, GoogleTiles))): + if _check_bokeh_mercator(data) or isinstance(data, GoogleTiles): data = data.url elif WebMapTileService and isinstance(data, WebMapTileService): pass diff --git a/geoviews/tests/test_import.py b/geoviews/tests/test_import.py index 66750249..b1a9baad 100644 --- a/geoviews/tests/test_import.py +++ b/geoviews/tests/test_import.py @@ -8,7 +8,7 @@ def test_no_blocklist_imports(): import sys import geoviews as gv - blocklist = {"panel", "IPython", "datashader", "iris", "dask"} + blocklist = {"panel", "IPython", "datashader", "iris", "dask", "bokeh.models"} mods = blocklist & set(sys.modules) if mods: