Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add_tile_layer doesn't accept arguments like max_zoom #227

Closed
johnowhitaker opened this issue Dec 17, 2020 · 2 comments
Closed

add_tile_layer doesn't accept arguments like max_zoom #227

johnowhitaker opened this issue Dec 17, 2020 · 2 comments
Assignees
Labels
enhancement improvements to geemap

Comments

@johnowhitaker
Copy link

Description

The default max_zoom of 18 wasn't quite enough for a project I was working on. I tried to add a tile layer (Google Satellite) with a higher max_zoom but the add_tile_layer only accepts url, name, attribution, opacity and shown as arguments

The additional ipyleaflet TileLayer options are listed at https://ipyleaflet.readthedocs.io/en/latest/api_reference/tile_layer.html. It would be nice to have a way to specify all of these arguments for more control.

What I Did

My temporary fix was to use fastcore to mix in my own version of the add_tile_layer function:

from fastcore.all import *

@patch
def add_tile_layer(self:geemap.Map, **kwargs): 
    try:
        tile_layer = ipyleaflet.TileLayer(**kwargs)
        self.add_layer(tile_layer)
    except Exception as e:
        print(e)
        print("Failed to add the specified TileLayer.")

# Now we can add a layer with max_zoom or any other TileLayer arguments
Map.add_tile_layer(url="https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}",
        attribution="Google",
        name="Google Satellite",
        max_zoom=24)

There are a couple of ways add_tile_layer in geemap.py could be modified to accept all the available arguments for TileLayer. Should be an easy feature to add if anyone is looking for something to work on, otherwise I'm happy to have a go once time allows.

Jonathan

  • geemap version: 0.7.11
  • Python version: 3.7.6
  • Operating System: Ubuntu 20.04.1
@giswqs giswqs added the enhancement improvements to geemap label Dec 17, 2020
@giswqs giswqs self-assigned this Dec 17, 2020
giswqs added a commit that referenced this issue Dec 17, 2020
@giswqs
Copy link
Member

giswqs commented Dec 17, 2020

@johnowhitaker Good suggestion. I just committed code to fix this. Please update the package using geemap.update_package() and try again.

@giswqs giswqs closed this as completed Dec 17, 2020
@johnowhitaker
Copy link
Author

Works like a charm! Many thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improvements to geemap
Projects
None yet
Development

No branches or pull requests

2 participants