我的代码是
from bokeh.io import output_file, show
from bokeh.models import ColumnDataSource, GMapOptions
import bokeh.plotting as plotting
from bokeh.plotting import gmap
import tkinter as tk
screenInfo=tk.Tk()
map_options = GMapOptions(lat=26.366314, lng= 77.016513, map_type="roadmap", zoom=5)
# 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(API_KEY, map_options, title="Austin",plot_width=screenInfo.winfo_screenwidth()-100, plot_height=screenInfo.winfo_screenheight()-100)
source = ColumnDataSource(
df
)
p.circle(x="lat", y="lon", size=15,name="Place", fill_color="blue", fill_alpha=0.8, source=source)
plotting.output_file('gmap.html')
show(p)
在这里,我需要为圆添加工具提示 我试过使用
TOOLTIPS = [
# ("index", "$index"),
# ("(x,y)", "($x, $y)"),
("Place", "@Place"),
]
p = gmap(API_KEY, map_options, tooltip=TOOLTIPS,title="The Hindu",plot_width=screenInfo.winfo_screenwidth()-100, plot_height=screenInfo.winfo_screenheight()-150)
但是工具提示仅适用于图形,不适用于 gmap。 那么,是否有其他方法可以获取工具提示。
终于我得到了解决方案
from bokeh.models import ColumnDataSource, GMapOptions,HoverTool
TOOLTIPS = [
("Place", "@Place"),
("News","@Title")
]
p.add_tools( HoverTool(tooltips=TOOLTIPS))
我将这些行附加到我的代码以获取工具提示