首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在python中使用google地图api

在python中使用google地图api
EN

Stack Overflow用户
提问于 2019-11-28 21:59:32
回答 1查看 634关注 0票数 0

我遵循this指南,从gmaps和python开始;

代码语言:javascript
运行
复制
import gmaps
import gmaps.datasets
import pandas as pd


def func():
    # Use google maps api
    gmaps.configure(api_key='MY_API_KEY')  # Fill in with your API key
    # Get the dataset
    earthquake_df = gmaps.datasets.load_dataset_as_df('earthquakes')
    # Get the locations from the data set
    locations = earthquake_df[['latitude', 'longitude']]
    # Get the magnitude from the data
    weights = earthquake_df['magnitude']
    # Set up your map
    fig = gmaps.figure()
    fig.add_layer(gmaps.heatmap_layer(locations, weights=weights))
    return fig

func()

我一直在使用指南中的代码(在pychram和jupyter笔记本上),但当我运行代码(pychram/jupyter/terminal)时,我得不到像指南中那样的输出映射。只是一个很好的老式的

代码语言:javascript
运行
复制
Process finished with exit code 0
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-11-28 23:17:42

首先通过运行jupyter nbextension list检查是否为jupyter启用了它。如果您没有看到jupyter-gmaps/extension enabled,那么需要在终端jupyter nbextension enable --py gmaps中运行这一行,然后运行一个新的jupyter笔记本。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59090574

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档