#-----------------------------------------------------------------------------# Copyright (c) Anaconda, Inc., and Bokeh Contributors.# All rights reserved.## The full license is in the file LICENSE.txt, distributed with this software.#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Boilerplate#-----------------------------------------------------------------------------from__future__importannotationsimportlogging# isort:skiplog=logging.getLogger(__name__)#-----------------------------------------------------------------------------# Imports#-----------------------------------------------------------------------------# Bokeh importsfrom..modelsimport(GMapPlot,LinearAxis,MercatorTicker,MercatorTickFormatter,Range1d,)from._figureimportBaseFigureOptionsfrom._plotimport_get_num_minor_ticksfrom._toolsimportprocess_active_tools,process_tools_argfrom.glyph_apiimportGlyphAPI#-----------------------------------------------------------------------------# Globals and constants#-----------------------------------------------------------------------------DEFAULT_TOOLS="pan,wheel_zoom,reset,help"__all__=('GMap','GMapFigureOptions','gmap',)#-----------------------------------------------------------------------------# General API#-----------------------------------------------------------------------------
[docs]classGMap(GMapPlot,GlyphAPI):''' A subclass of |Plot| that simplifies plot creation with default axes, grids, tools, etc. Args: google_api_key (str): Google requires an API key be supplied for maps to function. See: https://developers.google.com/maps/documentation/javascript/get-api-key map_options: (:class:`~bokeh.models.map_plots.GMapOptions`) Configuration specific to a Google Map In addition to all the Bokeh model property attributes documented below, the ``Figure`` initializer also accepts the following options, which can help simplify configuration: .. bokeh-options:: GMapFigureOptions :module: bokeh.plotting.gmap '''def__init__(self,**kw)->None:opts=GMapFigureOptions(kw)super().__init__(x_range=Range1d(),y_range=Range1d(),**kw)ifopts.x_axis_locationisnotNone:xf=MercatorTickFormatter(dimension="lon")xt=MercatorTicker(dimension="lon")xt.num_minor_ticks=_get_num_minor_ticks(LinearAxis,opts.x_minor_ticks)self.add_layout(LinearAxis(formatter=xf,ticker=xt,axis_label=opts.x_axis_label),opts.x_axis_location)ifopts.y_axis_locationisnotNone:yf=MercatorTickFormatter(dimension="lat")yt=MercatorTicker(dimension="lat")yt.num_minor_ticks=_get_num_minor_ticks(LinearAxis,opts.y_minor_ticks)self.add_layout(LinearAxis(formatter=yf,ticker=yt,axis_label=opts.y_axis_label),opts.y_axis_location)tool_objs,tool_map=process_tools_arg(self,opts.tools,opts.tooltips)self.add_tools(*tool_objs)process_active_tools(self.toolbar,tool_map,opts.active_drag,opts.active_inspect,opts.active_scroll,opts.active_tap,opts.active_multi,)@propertydefplot(self):returnself@propertydefcoordinates(self):returnNone
[docs]defgmap(google_api_key,map_options,**kwargs)->GMap:''' Create a new :class:`~bokeh.plotting.GMap` for plotting. Args: google_api_key (str): Google requires an API key be supplied for maps to function. See: https://developers.google.com/maps/documentation/javascript/get-api-key The Google API key will be stored as a base64-encoded string in the Bokeh Document JSON. map_options: (:class:`~bokeh.models.map_plots.GMapOptions`) Configuration specific to a Google Map All other keyword arguments are passed to :class:`~bokeh.plotting.GMap`. Returns: :class:`~bokeh.plotting.GMap` '''returnGMap(api_key=google_api_key,map_options=map_options,**kwargs)
#-----------------------------------------------------------------------------# Dev API#-----------------------------------------------------------------------------classGMapFigureOptions(BaseFigureOptions):pass#-----------------------------------------------------------------------------# Private API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Code#-----------------------------------------------------------------------------