在Google Colaboratory中输出Ipleaflet小部件

时间:2018-05-15 18:50:30

标签: jupyter-notebook google-colaboratory

Google Colaboratory中,我尝试使用以下命令安装Ipleaflet

!pip install ipyleaflet

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

根据输出正确安装,但是当我使用代码时:

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

我收到的输出是文字:

地图(底图= {' url':' https:// {s} .tile.openstreetmap.org / {z} / {x} / {y}。 png',' max_zoom':19,'归因':'地图...... 而不是地图。

有没有办法让Google-Colaboratory能够输出这种小部件?是否需要安装其他库?

我已经在我的电脑上的Jupyter笔记本中测试了代码(取自Ipleaflet文档)并且工作正常。

1 个答案:

答案 0 :(得分:1)

ipyleaflet尚未与colab一起使用。

Colab不支持使用Jupyter小部件的任何内容。

您也可以使用folium。它也使用里面的传单。我做了一个示例笔记本here