在Python散景中可以用基於縮放的動態尺寸在GMapPlot
畫布上繪製Circle()
字形對象嗎?我想顯示一個圓形區域,其中有中心點和半徑(米)。我希望根據縮放Google地圖,以更小和更大的尺寸顯示此圈子。Python散景谷歌地圖基於變焦的動態字形尺寸
這可以通過某種方式實現嗎?
UPDATE: 我可以繪製固定大小的圓形用下面的代碼:
from bokeh.document import Document
from bokeh.embed import file_html
from bokeh.resources import INLINE
from bokeh.models import (GMapPlot, GMapOptions, ColumnDataSource,
Circle, DataRange1d, PanTool, WheelZoomTool, BoxSelectTool)
map_options = GMapOptions(lat=30.29, lng=-97.73, map_type="roadmap", zoom=11)
plot = GMapPlot(x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options,
title="Austin", api_key=GOOGLE_API_KEY)
source = ColumnDataSource(data=dict(lat=[30.29, 30.20, 30.29],
lon=[-97.70, -97.74, -97.78],))
circle = Circle(x="lon", y="lat", size=15, fill_color="blue", fill_alpha=0.8,
line_color=None)
plot.add_glyph(source, circle)
plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool())
# Save HTML file
doc = Document()
doc.add_root(plot)
filename = './google_maps_test.html'
with open(filename, "w") as f:
f.write(file_html(doc, INLINE, 'Google Maps plot'))
這裏size=15
意味着像素或一些固定尺寸時,我滾動圖,其不改變...我可以在我的ColumnDataSource
對象中有一個radius
,其中值將以米爲單位的半徑(例如50,75,100)。我會用size=radius
...
謝謝!
你已經試過了什麼? – bigreddot
我用示例代碼更新了我的問題... – ragesz