From 4dd3970bc8f2badf37bafe6d7fbdaec0182193cb Mon Sep 17 00:00:00 2001 From: Qiusheng Wu Date: Tue, 3 Aug 2021 22:19:09 -0400 Subject: [PATCH] Changed default basemap #91 --- README.md | 160 ++++++++++++++++++++--------------------- leafmap/basemaps.py | 5 ++ leafmap/foliumap.py | 53 ++------------ leafmap/leafmap.py | 47 +++--------- leafmap/toolbar.py | 12 ++-- tests/test_foliumap.py | 18 ++--- tests/test_leafmap.py | 18 ++--- 7 files changed, 129 insertions(+), 184 deletions(-) diff --git a/README.md b/README.md index 77485aebdb..de2312167a 100644 --- a/README.md +++ b/README.md @@ -1,80 +1,80 @@ -# Welcome to leafmap - -[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://gishub.org/leafmap-colab) -[![image](https://binder.pangeo.io/badge_logo.svg)](https://gishub.org/leafmap-pangeo) -[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/leafmap-binder) -[![image](https://img.shields.io/pypi/v/leafmap.svg)](https://pypi.python.org/pypi/leafmap) -[![image](https://img.shields.io/conda/vn/conda-forge/leafmap.svg)](https://anaconda.org/conda-forge/leafmap) -[![image](https://pepy.tech/badge/leafmap)](https://pepy.tech/project/leafmap) -[![image](https://github.com/giswqs/leafmap/workflows/docs/badge.svg)](https://leafmap.org) -[![image](https://github.com/giswqs/leafmap/workflows/build/badge.svg)](https://github.com/giswqs/leafmap/actions?query=workflow%3Abuild) -[![image](https://img.shields.io/lgtm/grade/python/g/giswqs/leafmap.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/giswqs/leafmap/context:python) -[![image](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) -[![image](https://img.shields.io/badge/YouTube-Channel-red)](https://www.youtube.com/c/QiushengWu) -[![image](https://img.shields.io/twitter/follow/giswqs?style=social)](https://twitter.com/giswqs) -[![status](https://joss.theoj.org/papers/10.21105/joss.03414/status.svg)](https://doi.org/10.21105/joss.03414) - -**A Python package for geospatial analysis and interactive mapping in a Jupyter environment.** - -- GitHub repo: -- Documentation: -- PyPI: -- Conda-forge: -- Leafmap tutorials on YouTube: -- Free software: [MIT license](https://opensource.org/licenses/MIT) - -## Introduction - -**Leafmap** is a Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment. It is a spin-off project of the [geemap](https://geemap.org) Python package, which was designed specifically to work with [Google Earth Engine](https://earthengine.google.com) (GEE). However, not everyone in the geospatial community has access to the GEE cloud computing platform. Leafmap is designed to fill this gap for non-GEE users. It is a free and open-source Python package that enables users to analyze and visualize geospatial data with minimal coding in a Jupyter environment, such as Google Colab, Jupyter Notebook, and JupyterLab. Leafmap is built upon several open-source packages, such as [folium](https://github.com/python-visualization/folium) and [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet) (for creating interactive maps), [WhiteboxTools](https://github.com/jblindsay/whitebox-tools) and [whiteboxgui](https://github.com/giswqs/whiteboxgui) (for analyzing geospatial data), and [ipywidgets](https://github.com/jupyter-widgets/ipywidgets) (for designing interactive graphical user interface [GUI]). Leafmap has a toolset with various interactive tools that allow users to load vector and raster data onto the map without coding. In addition, users can use the powerful analytical backend (i.e., WhiteboxTools) to perform geospatial analysis directly within the leafmap user interface without writing a single line of code. The WhiteboxTools library currently contains **468** tools for advanced geospatial analysis, such as [GIS Analysis](https://jblindsay.github.io/wbt_book/available_tools/gis_analysis.html), [Geomorphometric Analysis](https://jblindsay.github.io/wbt_book/available_tools/geomorphometric_analysis.html), [Hydrological Analysis](https://jblindsay.github.io/wbt_book/available_tools/hydrological_analysis.html), [LiDAR Data Analysis](https://jblindsay.github.io/wbt_book/available_tools/lidar_tools.html), [Mathematical and Statistical Analysis](https://jblindsay.github.io/wbt_book/available_tools/mathand_stats_tools.html), and [Stream Network Analysis](https://jblindsay.github.io/wbt_book/available_tools/stream_network_analysis.html). - -## Statement of Need - -There are a plethora of Python packages for geospatial analysis, such as [geopandas](https://github.com/geopandas/geopandas) for vector data analysis and [xarray](https://github.com/pydata/xarray) for raster data analysis. However, few Python packages provide interactive GUIs for loading geospatial data in a Jupyter environment. It might take many lines to code to load and display geospatial data with various file formats on an interactive map, which can be a challenging task for novice users with limited coding skills. There are also some notable Python packages for visualizing geospatial data in a Jupyter environment, such as [plotly](https://github.com/plotly/plotly.py) and [kepler.gl](https://docs.kepler.gl/docs/keplergl-jupyter). However, plotly is designed for displaying static data, which lacks bidirectional communication between the front-end and the backend. Kepler.gl provides unique 3D functionality for visualizing large-scale geospatial datasets, but it lacks tools for performing geospatial analysis, such as hydrological analysis and LiDAR data analysis. In contrast, leafmap provides many convenient functions for loading and visualizing geospatial datasets with only one line of code. Users can also use the interactive GUI to load geospatial datasets without coding. Leafmap is intended for anyone who would like to analyze and visualize geospatial data interactively in a Jupyter environment. It is particularly suited for novice users with limited programming skills. Advanced programmers can also find leafmap a useful tool for analyzing geospatial data and building interactive web apps. - -Launch the interactive notebook tutorial for the **leafmap** Python package with Google Colab or Binder now: - -[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://gishub.org/leafmap-colab) -[![image](https://binder.pangeo.io/badge_logo.svg)](https://binder.pangeo.io/v2/gh/giswqs/leafmap/master) - -Check out this excellent article on Medium - [Leafmap a new Python Package for Geospatial data science](https://link.medium.com/HRRKDcynYgb) - -To learn more about leafmap, check out the leafmap documentation website - - -![](https://i.imgur.com/abd8pTH.gif) - -## Key Features - -Below is a partial list of features available for the leafmap package. Please check the [examples](https://github.com/giswqs/leafmap/tree/master/examples) page for notebook examples, GIF animations, and video tutorials. - -- Create an interactive map with only one-line of code. -- Select from a variety of basemaps interactively without coding. -- Add XYZ, WMS, and vector tile services to the map. -- Convert CSV to points and display points as a marker cluster. -- Add local vector data (e.g., shapefile, GeoJSON, KML) to the map without coding. -- Add local raster data (e.g., GeoTIFF) to the map without coding. -- Add Cloud Optimized GeoTIFF (COG) and SpatialTemporal Asset Catalog (STAC) to the map. -- Add OpenStreetMap data to the map with a single line of code. -- Add a GeoPandas GeoDataFrame to the map with a single line of code. -- Add a point layer with popup attributes to the map. -- Add data from a PostGIS database to the map. -- Add custom legends and colorbars to the map. -- Perform geospatial analysis using WhiteboxTools and whiteboxgui. -- Create split-panel map and linked maps. -- Publish interactive maps with a single line of code. -- Download and display OpenStreetMap data with a single line of code. - -## Citations - -If you find **leafmap** useful in your research, please consider citing the following paper to support my work. Thank you for your support. - -- Wu, Q. (2021). Leafmap: A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment. _Journal of Open Source Software_, 6(63), 3414. - -## Demo - -![](https://wetlands.io/file/images/leafmap_demo.gif) - -## YouTube Channel - -I have created a [YouTube Channel](https://www.youtube.com/c/QiushengWu) for sharing geospatial tutorials. You can subscribe to my channel for regular updates. If there is any specific tutorial you would like to see, please submit a feature request [here](https://github.com/giswqs/leafmap/issues). - -[![Earth Engine Tutorials on YouTube](https://wetlands.io/file/images/youtube.png)](https://www.youtube.com/c/QiushengWu) +# Welcome to leafmap + +[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://gishub.org/leafmap-colab) +[![image](https://binder.pangeo.io/badge_logo.svg)](https://gishub.org/leafmap-pangeo) +[![image](https://mybinder.org/badge_logo.svg)](https://gishub.org/leafmap-binder) +[![image](https://img.shields.io/pypi/v/leafmap.svg)](https://pypi.python.org/pypi/leafmap) +[![image](https://img.shields.io/conda/vn/conda-forge/leafmap.svg)](https://anaconda.org/conda-forge/leafmap) +[![image](https://pepy.tech/badge/leafmap)](https://pepy.tech/project/leafmap) +[![image](https://github.com/giswqs/leafmap/workflows/docs/badge.svg)](https://leafmap.org) +[![image](https://github.com/giswqs/leafmap/workflows/build/badge.svg)](https://github.com/giswqs/leafmap/actions?query=workflow%3Abuild) +[![image](https://img.shields.io/lgtm/grade/python/g/giswqs/leafmap.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/giswqs/leafmap/context:python) +[![image](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) +[![image](https://img.shields.io/badge/YouTube-Channel-red)](https://www.youtube.com/c/QiushengWu) +[![image](https://img.shields.io/twitter/follow/giswqs?style=social)](https://twitter.com/giswqs) +[![status](https://joss.theoj.org/papers/10.21105/joss.03414/status.svg)](https://doi.org/10.21105/joss.03414) + +**A Python package for geospatial analysis and interactive mapping in a Jupyter environment.** + +- GitHub repo: +- Documentation: +- PyPI: +- Conda-forge: +- Leafmap tutorials on YouTube: +- Free software: [MIT license](https://opensource.org/licenses/MIT) + +## Introduction + +**Leafmap** is a Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment. It is a spin-off project of the [geemap](https://geemap.org) Python package, which was designed specifically to work with [Google Earth Engine](https://earthengine.google.com) (GEE). However, not everyone in the geospatial community has access to the GEE cloud computing platform. Leafmap is designed to fill this gap for non-GEE users. It is a free and open-source Python package that enables users to analyze and visualize geospatial data with minimal coding in a Jupyter environment, such as Google Colab, Jupyter Notebook, and JupyterLab. Leafmap is built upon several open-source packages, such as [folium](https://github.com/python-visualization/folium) and [ipyleaflet](https://github.com/jupyter-widgets/ipyleaflet) (for creating interactive maps), [WhiteboxTools](https://github.com/jblindsay/whitebox-tools) and [whiteboxgui](https://github.com/giswqs/whiteboxgui) (for analyzing geospatial data), and [ipywidgets](https://github.com/jupyter-widgets/ipywidgets) (for designing interactive graphical user interface [GUI]). Leafmap has a toolset with various interactive tools that allow users to load vector and raster data onto the map without coding. In addition, users can use the powerful analytical backend (i.e., WhiteboxTools) to perform geospatial analysis directly within the leafmap user interface without writing a single line of code. The WhiteboxTools library currently contains **468** tools for advanced geospatial analysis, such as [GIS Analysis](https://jblindsay.github.io/wbt_book/available_tools/gis_analysis.html), [Geomorphometric Analysis](https://jblindsay.github.io/wbt_book/available_tools/geomorphometric_analysis.html), [Hydrological Analysis](https://jblindsay.github.io/wbt_book/available_tools/hydrological_analysis.html), [LiDAR Data Analysis](https://jblindsay.github.io/wbt_book/available_tools/lidar_tools.html), [Mathematical and Statistical Analysis](https://jblindsay.github.io/wbt_book/available_tools/mathand_stats_tools.html), and [Stream Network Analysis](https://jblindsay.github.io/wbt_book/available_tools/stream_network_analysis.html). + +## Statement of Need + +There are a plethora of Python packages for geospatial analysis, such as [geopandas](https://github.com/geopandas/geopandas) for vector data analysis and [xarray](https://github.com/pydata/xarray) for raster data analysis. However, few Python packages provide interactive GUIs for loading geospatial data in a Jupyter environment. It might take many lines to code to load and display geospatial data with various file formats on an interactive map, which can be a challenging task for novice users with limited coding skills. There are also some notable Python packages for visualizing geospatial data in a Jupyter environment, such as [plotly](https://github.com/plotly/plotly.py) and [kepler.gl](https://docs.kepler.gl/docs/keplergl-jupyter). However, plotly is designed for displaying static data, which lacks bidirectional communication between the front-end and the backend. Kepler.gl provides unique 3D functionality for visualizing large-scale geospatial datasets, but it lacks tools for performing geospatial analysis, such as hydrological analysis and LiDAR data analysis. In contrast, leafmap provides many convenient functions for loading and visualizing geospatial datasets with only one line of code. Users can also use the interactive GUI to load geospatial datasets without coding. Leafmap is intended for anyone who would like to analyze and visualize geospatial data interactively in a Jupyter environment. It is particularly suited for novice users with limited programming skills. Advanced programmers can also find leafmap a useful tool for analyzing geospatial data and building interactive web apps. + +Launch the interactive notebook tutorial for the **leafmap** Python package with Google Colab or Binder now: + +[![image](https://colab.research.google.com/assets/colab-badge.svg)](https://gishub.org/leafmap-colab) +[![image](https://binder.pangeo.io/badge_logo.svg)](https://binder.pangeo.io/v2/gh/giswqs/leafmap/master) + +Check out this excellent article on Medium - [Leafmap a new Python Package for Geospatial data science](https://link.medium.com/HRRKDcynYgb) + +To learn more about leafmap, check out the leafmap documentation website - + +![](https://i.imgur.com/abd8pTH.gif) + +## Key Features + +Below is a partial list of features available for the leafmap package. Please check the [examples](https://github.com/giswqs/leafmap/tree/master/examples) page for notebook examples, GIF animations, and video tutorials. + +- Create an interactive map with only one-line of code. +- Select from a variety of basemaps interactively without coding. +- Add XYZ, WMS, and vector tile services to the map. +- Convert CSV to points and display points as a marker cluster. +- Add local vector data (e.g., shapefile, GeoJSON, KML) to the map without coding. +- Add local raster data (e.g., GeoTIFF) to the map without coding. +- Add Cloud Optimized GeoTIFF (COG) and SpatialTemporal Asset Catalog (STAC) to the map. +- Add OpenStreetMap data to the map with a single line of code. +- Add a GeoPandas GeoDataFrame to the map with a single line of code. +- Add a point layer with popup attributes to the map. +- Add data from a PostGIS database to the map. +- Add custom legends and colorbars to the map. +- Perform geospatial analysis using WhiteboxTools and whiteboxgui. +- Create split-panel map and linked maps. +- Publish interactive maps with a single line of code. +- Download and display OpenStreetMap data with a single line of code. + +## Citations + +If you find **leafmap** useful in your research, please consider citing the following paper to support my work. Thank you for your support. + +- Wu, Q. (2021). Leafmap: A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment. _Journal of Open Source Software_, 6(63), 3414. + +## Demo + +![](https://wetlands.io/file/images/leafmap_demo.gif) + +## YouTube Channel + +I have created a [YouTube Channel](https://www.youtube.com/c/QiushengWu) for sharing geospatial tutorials. You can subscribe to my channel for regular updates. If there is any specific tutorial you would like to see, please submit a feature request [here](https://github.com/giswqs/leafmap/issues). + +[![Earth Engine Tutorials on YouTube](https://wetlands.io/file/images/youtube.png)](https://www.youtube.com/c/QiushengWu) diff --git a/leafmap/basemaps.py b/leafmap/basemaps.py index e9f1548bdd..ce3786c696 100644 --- a/leafmap/basemaps.py +++ b/leafmap/basemaps.py @@ -21,6 +21,11 @@ leaf_basemaps = { + "OpenStreetMap": TileLayer( + url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", + attribution="OpenStreetMap", + name="OpenStreetMap", + ), "ROADMAP": TileLayer( url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}", attribution="Google", diff --git a/leafmap/foliumap.py b/leafmap/foliumap.py index a7d521cd93..de6b0a22c3 100644 --- a/leafmap/foliumap.py +++ b/leafmap/foliumap.py @@ -8,7 +8,7 @@ class Map(folium.Map): - """The Map class inherits folium.Map. By default, the Map will add Google Maps as the basemap. + """The Map class inherits folium.Map. By default, the Map will add OpenStreetMap as the basemap. Returns: object: folium map object. @@ -91,60 +91,21 @@ def __init__(self, **kwargs): plugins.MiniMap().add_to(self) if "google_map" not in kwargs: - layer = folium.TileLayer( - tiles="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}", - attr="Google", - name="Google Maps", - overlay=True, - control=True, - ) - layer.add_to(self) - elif kwargs["google_map"] is None: pass - else: + elif kwargs["google_map"] is not None: if kwargs["google_map"].upper() == "ROADMAP": - layer = folium.TileLayer( - tiles="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}", - attr="Google", - name="Google Maps", - overlay=True, - control=True, - ) + layer = folium_basemaps["ROADMAP"] elif kwargs["google_map"].upper() == "HYBRID": - layer = folium.TileLayer( - tiles="https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}", - attr="Google", - name="Google Satellite", - overlay=True, - control=True, - ) + layer = folium_basemaps["HYBRID"] elif kwargs["google_map"].upper() == "TERRAIN": - layer = folium.TileLayer( - tiles="https://mt1.google.com/vt/lyrs=p&x={x}&y={y}&z={z}", - attr="Google", - name="Google Terrain", - overlay=True, - control=True, - ) + layer = folium_basemaps["TERRAIN"] elif kwargs["google_map"].upper() == "SATELLITE": - layer = folium.TileLayer( - tiles="https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}", - attr="Google", - name="Google Satellite", - overlay=True, - control=True, - ) + layer = folium_basemaps["SATELLITE"] else: print( f'{kwargs["google_map"]} is invalid. google_map must be one of: ["ROADMAP", "HYBRID", "TERRAIN", "SATELLITE"]. Adding the default ROADMAP.' ) - layer = folium.TileLayer( - tiles="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}", - attr="Google", - name="Google Maps", - overlay=True, - control=True, - ) + layer = folium_basemaps["ROADMAP"] layer.add_to(self) if "layers_control" not in kwargs: diff --git a/leafmap/leafmap.py b/leafmap/leafmap.py index 1df301fa56..9d0cdc799f 100644 --- a/leafmap/leafmap.py +++ b/leafmap/leafmap.py @@ -10,7 +10,7 @@ class Map(ipyleaflet.Map): - """The Map class inherits ipyleaflet.Map. The arguments you can pass to the Map can be found at https://ipyleaflet.readthedocs.io/en/latest/api_reference/map.html. By default, the Map will add Google Maps as the basemap. Set add_google_map = False to use OpenStreetMap as the basemap. + """The Map class inherits ipyleaflet.Map. The arguments you can pass to the Map can be found at https://ipyleaflet.readthedocs.io/en/latest/api_reference/map.html. By default, the Map will add OpenStreetMap as the basemap. Returns: object: ipyleaflet map object. @@ -98,49 +98,25 @@ def handle_draw(target, action, geo_json): if kwargs["scale_control"]: self.add_control(ipyleaflet.ScaleControl(position="bottomleft")) + self.clear_layers() + self.add_layer(basemap_tiles["OpenStreetMap"]) + if "google_map" not in kwargs: - layer = ipyleaflet.TileLayer( - url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}", - attribution="Google", - name="Google Maps", - ) - self.add_layer(layer) - elif kwargs["google_map"] is None: pass - else: + elif kwargs["google_map"] is not None: if kwargs["google_map"].upper() == "ROADMAP": - layer = ipyleaflet.TileLayer( - url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}", - attribution="Google", - name="Google Maps", - ) + layer = basemap_tiles["ROADMAP"] elif kwargs["google_map"].upper() == "HYBRID": - layer = ipyleaflet.TileLayer( - url="https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}", - attribution="Google", - name="Google Satellite", - ) + layer = basemap_tiles["HYBRID"] elif kwargs["google_map"].upper() == "TERRAIN": - layer = ipyleaflet.TileLayer( - url="https://mt1.google.com/vt/lyrs=p&x={x}&y={y}&z={z}", - attribution="Google", - name="Google Terrain", - ) + layer = basemap_tiles["TERRAIN"] elif kwargs["google_map"].upper() == "SATELLITE": - layer = ipyleaflet.TileLayer( - url="https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}", - attribution="Google", - name="Google Satellite", - ) + layer = basemap_tiles["SATELLITE"] else: print( f'{kwargs["google_map"]} is invalid. google_map must be one of: ["ROADMAP", "HYBRID", "TERRAIN", "SATELLITE"]. Adding the default ROADMAP.' ) - layer = ipyleaflet.TileLayer( - url="https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}", - attribution="Google", - name="Google Maps", - ) + layer = basemap_tiles["ROADMAP"] self.add_layer(layer) if "toolbar_control" not in kwargs: @@ -2433,7 +2409,6 @@ def linked_maps( m = Map( height=height, - google_map=None, layout=widgets.Layout(margin="0px", padding="0px"), **kwargs, ) @@ -2592,7 +2567,7 @@ def ts_inspector( left_layer = layers_dict[left_name] right_layer = layers_dict[right_name] - m = Map(center=center, zoom=zoom, google_map=None, **kwargs) + m = Map(center=center, zoom=zoom, **kwargs) control = ipyleaflet.SplitMapControl(left_layer=left_layer, right_layer=right_layer) m.add_control(control) diff --git a/leafmap/toolbar.py b/leafmap/toolbar.py index 545e60027a..ec047aa015 100644 --- a/leafmap/toolbar.py +++ b/leafmap/toolbar.py @@ -415,7 +415,7 @@ def all_layers_chk_changed(change): layers = [ lyr - for lyr in m.layers[1:] + for lyr in m.layers if ( isinstance(lyr, ipyleaflet.TileLayer) or isinstance(lyr, ipyleaflet.WMSLayer) @@ -843,11 +843,15 @@ def change_basemap(m): """ from .basemaps import leaf_basemaps + value = "OpenStreetMap.Mapnik" + if len(m.layers) > 0: + if m.layers[0].name in list(leaf_basemaps.keys()): + value = m.layers[0].name + dropdown = widgets.Dropdown( options=list(leaf_basemaps.keys()), - value="ROADMAP", - layout=widgets.Layout(width="200px") - # description="Basemaps", + value=value, + layout=widgets.Layout(width="200px"), ) close_btn = widgets.Button( diff --git a/tests/test_foliumap.py b/tests/test_foliumap.py index 75f159231a..4b1bddc478 100644 --- a/tests/test_foliumap.py +++ b/tests/test_foliumap.py @@ -373,19 +373,19 @@ def test_find_layer(self): with self.assertRaises(NotImplementedError): m = leafmap.Map() self.assertIsNone(m.find_layer("HYBRID")) - self.assertIsNotNone(m.find_layer("Google Maps")) + self.assertIsNotNone(m.find_layer("OpenStreetMap")) def test_find_layer_index(self): with self.assertRaises(NotImplementedError): """Check finding layer index""" m = leafmap.Map() - self.assertEqual(m.find_layer_index("Google Maps"), 1) + self.assertEqual(m.find_layer_index("OpenStreetMap"), 0) def test_get_layer_names(self): """Check getting layer names""" with self.assertRaises(NotImplementedError): m = leafmap.Map() - assert "Google Maps" in m.get_layer_names() + assert "OpenStreetMap" in m.get_layer_names() def test_get_scale(self): """Check getting scale""" @@ -407,8 +407,8 @@ def test_layer_opacity(self): """Check layer opacity""" with self.assertRaises(NotImplementedError): m = leafmap.Map() - m.layer_opacity("Google Maps", 0.5) - layer = m.find_layer("Google Maps") + m.layer_opacity("OpenStreetMap", 0.5) + layer = m.find_layer("OpenStreetMap") self.assertEqual(layer.opacity, 0.5) def test_set_center(self): @@ -430,7 +430,7 @@ def test_to_html(self): """Check map to html""" m = leafmap.Map() out_str = m.to_html() - assert "Google Maps" in out_str + assert "OpenStreetMap" in out_str def test_to_image(self): """Check map to image""" @@ -465,7 +465,7 @@ def test_zoom_to_bounds(self): bounds = [13, -130, 32, -100] m.zoom_to_bounds(bounds) out_str = m.to_html() - assert "Google Maps" in out_str + assert "OpenStreetMap" in out_str def test_zoom_to_gdf(self): """Check zoom to GeoDataFrame""" @@ -475,14 +475,14 @@ def test_zoom_to_gdf(self): ) m.zoom_to_gdf(gdf) out_str = m.to_html() - assert "Google Maps" in out_str + assert "OpenStreetMap" in out_str def test_leafmap_split_map(self): """Check split-panel map""" with self.assertRaises(NotImplementedError): m = leafmap.split_map(left_layer="ROADMAP", right_layer="HYBRID") out_str = m.to_html() - assert "Google Maps" in out_str + assert "OpenStreetMap" in out_str def test_linked_maps(self): """Check linked maps""" diff --git a/tests/test_leafmap.py b/tests/test_leafmap.py index f7f50e5112..2c4274b8c5 100644 --- a/tests/test_leafmap.py +++ b/tests/test_leafmap.py @@ -363,17 +363,17 @@ def test_find_layer(self): """Check finding layer""" m = leafmap.Map() self.assertIsNone(m.find_layer("HYBRID")) - self.assertIsNotNone(m.find_layer("Google Maps")) + self.assertIsNotNone(m.find_layer("OpenStreetMap")) def test_find_layer_index(self): """Check finding layer index""" m = leafmap.Map() - self.assertEqual(m.find_layer_index("Google Maps"), 1) + self.assertEqual(m.find_layer_index("OpenStreetMap"), 0) def test_get_layer_names(self): """Check getting layer names""" m = leafmap.Map() - assert "Google Maps" in m.get_layer_names() + assert "OpenStreetMap" in m.get_layer_names() def test_get_scale(self): """Check getting scale""" @@ -392,8 +392,8 @@ def test_image_overlay(self): def test_layer_opacity(self): """Check layer opacity""" m = leafmap.Map() - m.layer_opacity("Google Maps", 0.5) - layer = m.find_layer("Google Maps") + m.layer_opacity("OpenStreetMap", 0.5) + layer = m.find_layer("OpenStreetMap") self.assertEqual(layer.opacity, 0.5) def test_set_center(self): @@ -413,7 +413,7 @@ def test_to_html(self): """Check map to html""" m = leafmap.Map() out_str = m.to_html() - assert "Google Maps" in out_str + assert "OpenStreetMap" in out_str # def test_to_image(self): # """Check map to image""" @@ -445,7 +445,7 @@ def test_zoom_to_bounds(self): bounds = [13, -130, 32, -100] m.zoom_to_bounds(bounds) out_str = m.to_html() - assert "Google Maps" in out_str + assert "OpenStreetMap" in out_str def test_zoom_to_gdf(self): """Check zoom to GeoDataFrame""" @@ -455,13 +455,13 @@ def test_zoom_to_gdf(self): ) m.zoom_to_gdf(gdf) out_str = m.to_html() - assert "Google Maps" in out_str + assert "OpenStreetMap" in out_str def test_leafmap_split_map(self): """Check split-panel map""" m = leafmap.split_map(left_layer="ROADMAP", right_layer="HYBRID") out_str = m.to_html() - assert "Google Maps" in out_str + assert "OpenStreetMap" in out_str def test_linked_maps(self): """Check linked maps"""