简体   繁体   English

如何在Python中为Bokeh Google Maps图设置经度和纬度范围?

[英]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.

相关问题 如何在散景中绘制经度和​​纬度 - How to plot Latitude and Longitude in Bokeh Python pygmaps无法解析经度和纬度以在Google地图上正确定位 - Python pygmaps not resolving latitude and longitude to correct location on google maps 使用 Cartopy (Python) 制作正交 plot 时,如何裁剪 map / 设置图像的纬度/经度边界? - When using Cartopy (Python) to make Orthographic plot, how to crop the map / set the latitude/longitude boundaries of image? 从谷歌地图中抓取城市的经度和纬度 - Scraping longitude and latitude of a city from Google Maps Python Selenium - 从地图上抓取纬度和经度 - Python Selenium - Webscrape Latitude and Longitude from the Maps 在 Python 3.6 中从 CSV 绘制纬度经度 - Plot latitude longitude from CSV in Python 3.6 如何在谷歌中将经纬度数据框放置为python的api - How to make a dataframe from latitude and longitude in google places api for python 如何使用 python 中的纬度和经度数据绘制地图并突出显示地图中的几个纬度和经度点? ints - How can i plot a map using Latitude and longitude data in python & Highlight few Latitude and Longitude points in the map ?ints 如何使用 python 获取纬度和经度 - How To Get Latitude & Longitude with python 如何对经度和纬度进行分箱并绘制分箱的密度? - How to bin longitude and latitude and plot the density of the bins?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM