Skip to content

Commit

Permalink
add support for GMap scale control (#5845)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryevdv committed Feb 4, 2017
1 parent 073a9e0 commit e113920
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion bokeh/models/map_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from ..core.enums import MapType
from ..core.has_props import abstract
from ..core.properties import Enum, Float, Instance, Int, JSON, Override, String
from ..core.properties import Bool, Enum, Float, Instance, Int, JSON, Override, String
from ..core.validation import error, warning
from ..core.validation.warnings import MISSING_RENDERERS, NO_DATA_RENDERERS
from ..core.validation.errors import REQUIRED_RANGE, MISSING_GOOGLE_API_KEY
Expand Down Expand Up @@ -48,6 +48,10 @@ class GMapOptions(MapOptions):
""")

scale_control = Bool(default=False, help="""
Whether the Google map should display its distance scale control.
""")

styles = JSON(help="""
A JSON array of `map styles`_ to use for the GMapPlot. Many example styles can
`be found here`_.
Expand Down
5 changes: 3 additions & 2 deletions bokehjs/src/coffee/models/plots/gmap_plot.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export class MapOptions extends Model
export class GMapOptions extends MapOptions
type: 'GMapOptions'
@define {
map_type: [ p.String, "roadmap" ]
styles: [ p.String ]
map_type: [ p.String, "roadmap" ]
scale_control: [ p.Bool, false ]
styles: [ p.String ]
}

export class GMapPlotView extends PlotView
Expand Down
6 changes: 6 additions & 0 deletions bokehjs/src/coffee/models/plots/gmap_plot_canvas.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class GMapPlotCanvasView extends PlotCanvasView
zoom:mo.zoom
disableDefaultUI: true
mapTypeId: @map_types[mo.map_type]
scaleControl: mo.scale_control
}

if mo.styles?
Expand All @@ -108,6 +109,7 @@ export class GMapPlotCanvasView extends PlotCanvasView
@listenTo(@model.plot.map_options, 'change:lng', () => @_update_center('lng'))
@listenTo(@model.plot.map_options, 'change:zoom', () => @_update_zoom())
@listenTo(@model.plot.map_options, 'change:map_type', () => @_update_map_type())
@listenTo(@model.plot.map_options, 'change:scale_control', () => @_update_scale_control())

_get_latlon_bounds: () =>
bounds = @map.getBounds()
Expand Down Expand Up @@ -141,6 +143,10 @@ export class GMapPlotCanvasView extends PlotCanvasView
maps = window.google.maps
@map.setOptions({mapTypeId: @map_types[@model.plot.map_options.map_type] })

_update_scale_control: () ->
maps = window.google.maps
@map.setOptions({scaleControl: @model.plot.map_options.scale_control })

_update_options: () ->
@_update_styles()
@_update_center('lat')
Expand Down

0 comments on commit e113920

Please sign in to comment.