opengeos / leafmap

A Python package for interactive mapping and geospatial analysis with minimal coding in a Jupyter environment
https://leafmap.org
MIT License
3.23k stars 388 forks source link

Error adding basemap to Lonboard Map #798

Closed spatialthoughts closed 5 months ago

spatialthoughts commented 5 months ago

Environment Information

Description

import leafmap.deckgl as leafmap
from lonboard import basemap

m = leafmap.Map(height=600, basemap_style=basemap.CartoBasemap.DarkMatterNoLabels)
m

This results in an error TypeError: ViewState.new() got an unexpected keyword argument 'basemap_style'.

Diving into the code, this seems to be because the kwargs are passed on to view_state and not lonboard.Map

        super().__init__(
            _height=height,
            show_tooltip=show_tooltip,
            layers=layers,
            view_state=kwargs,
        )
giswqs commented 5 months ago

Try this:

import leafmap.deckgl as leafmap
from lonboard import basemap

m = leafmap.Map(height=600)
m.add_basemap("CartoDB.DarkMatterNoLabels")
m
spatialthoughts commented 5 months ago

This gives AttributeError: 'Map' object has no attribute 'add_basemap' error

Reproducible example on Colab https://colab.research.google.com/drive/1TEG2_7WEUwkcfoKb4zxx2NE5P8OYdfuz?usp=sharing

giswqs commented 5 months ago

Thank you for report. It has been fixed in #799. Please update it to v0.35.1

import leafmap.deckgl as leafmap
from lonboard import basemap

m = leafmap.Map(height=600, basemap_style=basemap.CartoBasemap.DarkMatterNoLabels)
m

image

spatialthoughts commented 5 months ago

Incredible! Less than 2 hours from bug report to fix to release. Upgraded and uses it to create the visualization I was after.

lonboard_rivers
giswqs commented 5 months ago

My pleasure. That was an easy fix. I should improve the lonboard module when I have time. There is still a lot of room for improvement.