我有一个带有几个Lat/ Lng数据点的bokeh Google地图图,我想使用Google maps v3 API的fitBounds()方法来设置缩放级别。
我有一个谷歌地图绘图,显示在我的网站上,并显示数据点,但我需要手动设置缩放。
import bokeh.io
import bokeh.models
import bokeh.plotting
import pandas as pd
data = {
'Latitude [deg]': [18.46, 25.7, 32.3],
'Longitude [deg]': [-66, -80.2, -64.8],
}
data_frame = pd.DataFrame.from_dict(data)
data_source = bokeh.models.ColumnDataSource(data_frame)
mean_lat = data_frame['Latitude [deg]'].mean()
mean_lng = data_frame['Longitude [deg]'].mean()
gmap_options = bokeh.models.GMapOptions(lat=mean_lat, lng=mean_lng, zoom=10, map_type='satellite')
xy_gmap = bokeh.plotting.gmap('SuPeRSeCrEtAPIkey', gmap_options)
xy_gmap.circle(x='Longitude [deg]', y='Latitude [deg]', source=data_source, color="red")
# A callback like this? Could make the call in JavaScript after the page is loaded, and update map zoom??
# xy_gmap.fitBounds(x='Longitude [deg]', y='Latitude [deg]', source=data_source)
bokeh.io.show(xy_gmap)
我希望地图的边界以尽可能低的缩放比例包含数据帧中的所有点(就像fitBounds()在Javascript中所做的那样)。目前,地图只能缩放到手动设置的级别。
https://stackoverflow.com/questions/56687744
复制相似问题