-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathgoogle_maps_stuff.py
More file actions
51 lines (41 loc) · 1.44 KB
/
google_maps_stuff.py
File metadata and controls
51 lines (41 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from bokeh.models import HoverTool
from bokeh.plotting import figure
from bokeh.plotting import ColumnDataSource as plotColumnDataSource
from bokeh.io import output_file, show
from bokeh.models import (
GMapPlot, GMapOptions, ColumnDataSource, Circle, DataRange1d, PanTool, WheelZoomTool, BoxSelectTool
)
map_options = GMapOptions(lat=42.3601, lng=-71.0589, map_type="roadmap", zoom=9)
plot = GMapPlot(
x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options, title="Massachusetts"
)
# source = ColumnDataSource(
# data=dict(
# lat=[42.3601, 42.2926],
# lon=[-71.0589, -71.2644],
# )
# )
data=dict(
x=[-71.0589, -71.2644],
y=[42.3601, 42.2926],
name=['Boston', 'Olin'],
address=['Boston Rite Aid', 'Olin The Awesomest']
)
source = plotColumnDataSource(data)
colormap = {'Boston': 'blue', 'Olin': 'green'}
colors = {colormap[x] for x in data['name']}
circle = Circle(x="x", y="y", size=15, fill_color=colors, fill_alpha=0.8)
plot.add_glyph(source, circle)
# TOOLS="pan,wheel_zoom,box_zoom,reset,hover,save"
# p = figure(title="Our Map", tools=TOOLS)
plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool(), HoverTool())
hover = plot.select_one(HoverTool)
hover.point_policy = "follow_mouse"
hover.tooltips = [
('Name', '@name'),
('Title', '@address')
# ("(Long, Lat)", "($x, $y)"),
]
# plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool(), hover())
output_file("gmap_plot.html")
show(plot)