在python中使用GoogleMapsAPI
我遵循指南,从gmapsapi和python开始在python中使用GoogleMapsAPI,python,google-maps-api-3,Python,Google Maps Api 3,我遵循指南,从gmapsapi和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.lo
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
通过运行
jupyter nbextension list
,首先检查它是否为jupyter启用。
如果你没有看到jupyter gmaps/extension enabled,那么你需要在terminal
jupyter nbextension enable--py gmaps中运行这一行,然后运行一个新的jupyter笔记本。我想你错过了最后一行,那就是调用fig
对不起,你是对的,编辑工作了!谢谢,但实际上gmplot也遇到了同样的问题。