Mithras
Mithras

Reputation: 203

Outputting an Ipleaflet widget in Google Colaboratory

In Google Colaboratory I have tried installing Ipleaflet using the command:

!pip install ipyleaflet

!jupyter nbextension enable --py --sys-prefix ipyleaflet

Which according to the output gets installed correctly however when I use the code:

from ipyleaflet import Map, basemaps, basemap_to_tiles

m = Map(center=(52.204793, 360.121558), zoom=9)

dark_matter_layer = basemap_to_tiles(basemaps.CartoDB.DarkMatter)
m.add_layer(dark_matter_layer)
m

The output I recieve is the text:

Map(basemap={'url': 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', 'max_zoom': 19, 'attribution': 'Map … rather than the map.

Is there a way to get Google-Colaboratory to be able to output this kind of a widget? Are there additional libraries that need to be installed?

I have tested the code (taken from the Ipleaflet documentation) in a Jupyter notebook on my PC and it works fine.

Upvotes: 2

Views: 1825

Answers (1)

korakot
korakot

Reputation: 40828

ipyleaflet doesn't work with colab yet.

Colab doesn't support anything using Jupyter widgets.

You can also use folium. It also uses leaflet inside. I make an example notebook here.

Upvotes: 1

Related Questions