[英]How to set longitude and latitude ranges for Bokeh Google Maps plot in Python?
I can only set zooms but I need to have a very specific position so I can overlay it over another plot. 我只能设置缩放比例,但是我需要有一个非常特定的位置,以便可以将其覆盖在另一个图上。 How I get a view just from the limits I specified below?
我如何从下面指定的限制中获得视图? Right now I can only set a zoom which is difficult for overlaying on another plot.
现在,我只能设置缩放比例,而该缩放比例很难叠加到另一个绘图上。
from bokeh.io import output_file, show
from bokeh.models import ColumnDataSource, GMapOptions
from bokeh.plotting import gmap
output_file("gmap.html")
lat_lims = (42.418574999999997, 42.420059000000002)
lon_lims = (-70.907111, -70.904135999999994)
map_options = GMapOptions(lat=np.mean(lat_lims), lng=np.mean(lon_lims), map_type="satellite", zoom=18)
# For GMaps to function, Google requires you obtain and enable an API key:
#
# https://developers.google.com/maps/documentation/javascript/get-api-key
#
# Replace the value below with your personal API key:
p = gmap(googlemaps_api_key, map_options)
show(p)
If you were running a Bokeh Server application, it is possible that the bounds could be returned back to Python in some way, but I'm afraid it is not possible in a standalone Bokeh document (ie HTML file) as you have. 如果您正在运行Bokeh Server应用程序,则可能会以某种方式将边界返回给Python,但恐怕无法像您一样在独立的Bokeh文档(即HTML文件)中实现。 We are constrained by the using the Google maps API, and the bounds you are asking for are only available once the JavaScript code executes in the browser.
使用Google Maps API限制了我们的使用范围,只有在浏览器中执行JavaScript代码后,您要求的范围才可用。 The Google API does not accept arbitrary user provided bounds, it only accepts a center/zoom, or a suggested region.
Google API不接受用户提供的任意范围,仅接受中心/缩放或建议的区域。 The real bounds are only computed and returned (to the browser) by Google API, and are never computed or available in Python.
实边界仅由Google API计算并返回(返回到浏览器),而从未在Python中计算或可用。
You might look at the non-google TileProvider plots that are available. 您可能会查看可用的非Google TileProvider绘图 。 Unlike with GMap plots, you yourself can set the map bounds.
与GMap绘图不同,您可以自己设置地图范围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.