我遵循this指南,从gmaps和python开始;
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)时,我得不到像指南中那样的输出映射。只是一个很好的老式的
Process finished with exit code 0
发布于 2019-11-28 23:17:42
首先通过运行jupyter nbextension list
检查是否为jupyter启用了它。如果您没有看到jupyter-gmaps/extension enabled
,那么需要在终端jupyter nbextension enable --py gmaps
中运行这一行,然后运行一个新的jupyter笔记本。
https://stackoverflow.com/questions/59090574
复制相似问题