opengeos/leafmap

Error adding basemap to Lonboard Map

spatialthoughts opened this issue · 5 comments

Environment Information

  • leafmap version: 0.35
  • Python version: 3.10
  • Operating System: Colab (Ubuntu)

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,
        )

Try this:

import leafmap.deckgl as leafmap
from lonboard import basemap

m = leafmap.Map(height=600)
m.add_basemap("CartoDB.DarkMatterNoLabels")
m

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

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

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

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.