当前位置: 首页>>代码示例>>Python>>正文


Python GMapPlot.add_tools方法代码示例

本文整理汇总了Python中bokeh.models.GMapPlot.add_tools方法的典型用法代码示例。如果您正苦于以下问题:Python GMapPlot.add_tools方法的具体用法?Python GMapPlot.add_tools怎么用?Python GMapPlot.add_tools使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.models.GMapPlot的用法示例。


在下文中一共展示了GMapPlot.add_tools方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_plot

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def create_plot(center_coords,zoom_level = 8):

    x_range = Range1d()
    y_range = Range1d()

    # JSON style string taken from: https://snazzymaps.com/style/1/pale-dawn
    map_options = GMapOptions(lat=center_coords['lat'], lng=center_coords['lng'], map_type="roadmap", zoom=zoom_level, styles="""
    [{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"on"},{"lightness":33}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2e5d4"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#c5dac6"}]},{"featureType":"poi.park","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":20}]},{"featureType":"road","elementType":"all","stylers":[{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#c5c6c6"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#e4d7c6"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#fbfaf7"}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"on"},{"color":"#acbcc9"}]}]
    """)

    plot = GMapPlot(
        x_range=x_range, y_range=y_range,
        map_options=map_options,
        title="Austin"
    )

    # source = ColumnDataSource(
    #     data=dict(
    #         lat=[30.2861, 30.2855, 30.2869],
    #         lon=[-97.7394, -97.7390, -97.7405],
    #         fill=['orange', 'blue', 'green']
    #     )
    # )

    # circle = Circle(x="lon", y="lat", size=15, fill_color="fill", line_color="black")
    # plot.add_glyph(source, circle)

    pan = PanTool()
    wheel_zoom = WheelZoomTool()
    box_select = BoxSelectTool()

    plot.add_tools(pan, wheel_zoom, box_select)
    return plot
开发者ID:sergeimoiseev,项目名称:othodi,代码行数:35,代码来源:bokeh_googlemaps_example.py

示例2: plotHTML

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def plotHTML(location, latlongDict):
    '''
    :param location: given a location & a dictionary of vicinity lat-longs of categories, this function will
     calculate bokeh map seperating the main locatin ( address) and the other vicinity based on the input
     and creates a object ( script & tag html ) of the chart which is rendered on the front end.
    :param latlongDict:
    :return:
    '''
    print("Found : {0} latitudes".format(len(latlongDict["latarr"])))
    print("Found : {0} longitudes".format(len(latlongDict["longarr"])))

    map_options = GMapOptions(lat=location.latitude, lng=location.longitude, map_type="roadmap", zoom=15)
    plot = GMapPlot(
        x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options, title="Austin"
    )
    source = ColumnDataSource(
        data=dict(
            lat=latlongDict["latarr"],
            lon=latlongDict["longarr"],
        ))
    # print([location.latitude,latlongDict["latarr"]])

    circle = Circle(x="lon", y="lat", size=10, fill_color="blue", fill_alpha=0.8, line_color=None)
    plot.add_glyph(source, circle)

    source = ColumnDataSource(
        data=dict(
            lat=[location.latitude],
            lon=[location.longitude],
        ))
    circle = Circle(x="lon", y="lat", size=15, fill_color="red", fill_alpha=0.8, line_color=None)
    plot.add_glyph(source, circle)
    plot.add_tools(PanTool(), BoxSelectTool(), BoxZoomTool())
    # return file_html(plot, CDN, "my plot")
    return (components(plot, CDN))  # Will return a (script, tag)
开发者ID:maulikthaker,项目名称:daily-dashboard,代码行数:37,代码来源:views.py

示例3: trail_map

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def trail_map(data):
    lon = (min(data.lon) + max(data.lon))/2
    lat = (min(data.lat) + max(data.lat))/2

    map_options = GMapOptions(lng=lon, lat=lat, zoom=13)
    plot = GMapPlot(title="%s - Trail Map" % title, map_options=map_options, plot_width=800, plot_height=800)

    xaxis = LinearAxis()
    plot.add_layout(xaxis, 'below')

    yaxis = LinearAxis()
    plot.add_layout(yaxis, 'left')

    xgrid = Grid(plot=plot, dimension=0, ticker=xaxis.ticker, grid_line_dash="dashed", grid_line_color="gray")
    ygrid = Grid(plot=plot, dimension=1, ticker=yaxis.ticker, grid_line_dash="dashed", grid_line_color="gray")
    plot.renderers.extend([xgrid, ygrid])

    plot.add_tools(PanTool(), WheelZoomTool(), ResetTool(), BoxSelectTool())

    line_source = ColumnDataSource(dict(x=data.lon, y=data.lat, dist=data.dist))

    line = Line(x="x", y="y", line_color="blue", line_width=2)
    plot.add_glyph(line_source, line)

    plot.x_range = DataRange1d(sources=[line_source.columns("x")])
    plot.y_range = DataRange1d(sources=[line_source.columns("y")])

    return plot
开发者ID:Wombatpm,项目名称:bokeh,代码行数:30,代码来源:trail.py

示例4: create_heatmap

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def create_heatmap(station_scores, plot_width=1000, plot_height=600):
    map_options = GMapOptions(lat=32.06, lng=34.87, map_type="roadmap", zoom=9)
    cmap = plt.get_cmap('jet')
    plot = GMapPlot(
        x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options, title="Israel"
    )
    plot.plot_width = plot_width
    plot.plot_height = plot_height
    lat_vec = list(map(lambda x: get_loc_by_id(x).lat, station_scores.keys()))
    lon_vec = list(map(lambda x: get_loc_by_id(x).lon, station_scores.keys()))

    for ind, station in enumerate(station_scores):

        source = ColumnDataSource(
            data=dict(
                lat=[lat_vec[ind]],
                lon=[lon_vec[ind]],
            )
        )
        cmap_indx = int(station_scores[station]*cmap.N)
        cmap_val = tuple(np.floor(255 * np.array(cmap(cmap_indx)[:3])))
        circle = Circle(x="lon", y="lat", size=17, fill_color=cmap_val, fill_alpha=0.95, line_color=None)
        plot.add_glyph(source, circle)

    plot.add_tools(PanTool(), WheelZoomTool())
    output_file("Mean Time to Tel-Aviv Hashalom.html")
    show(plot)
开发者ID:hasadna,项目名称:OpenTrainCommunity,代码行数:29,代码来源:heatmap.py

示例5: create_map

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def create_map(tab_del_file):
    """
    This function was adapted from bokeh tutorial, so it might have similar
     elements in it.
    """
    data = pandas.read_csv(tab_del_file, sep="\\t", engine='python')
    lat_mean = data["Lat"].mean()
    long_mean = data["Long"].mean()
    map_options = GMapOptions(lat=lat_mean, lng=long_mean, map_type="hybrid",
                              zoom=5)
    plot = GMapPlot(x_range=DataRange1d(),
                    y_range=DataRange1d(),
                    map_options=map_options,
                    title="PopART-XTREME"
                    )
    source = ColumnDataSource(data=dict(lat=[x for x in data["Lat"]],
                                        lon=[y for y in data["Long"]],
                                        name=[s for s in data["Sequence"]],
                                        local=[l for l in data["Locality"]]))
    circle = Circle(x="lon", y="lat", size=15, fill_color="blue",
                    fill_alpha=0.8, line_color=None)
    tooltips = [("Sequence", "@name"), ("Locality", "@local")]

    render = plot.add_glyph(source, circle)
    plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool(), BoxZoomTool(),
                   PreviewSaveTool(), HoverTool(tooltips=tooltips,
                   renderers=[render]))
    output_file("map_plot.html")
    show(plot)
开发者ID:AndreMonc,项目名称:PopART_Xtreme,代码行数:31,代码来源:PopART_Xtreme.py

示例6: createMap

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def createMap(data, selectorColumn='MetricName'):
    # unique names
    ops = list(data[selectorColumn].unique())

    # data
    msk = data[selectorColumn] == ops[0]
    source = ColumnDataSource(data=dict(lat=data['Latitude'][msk], lon=data['Longitude'][msk],
                                        disp=data['DisplayName'][msk], metric=data['MetricName'][msk],
                                        name=data['OrganisationName'][msk],
                                        value=data['Value'][msk]))

    all = {}
    for o in ops:
        msk = data[selectorColumn] == o
        all[o] = dict(lat=data['Latitude'][msk], lon=data['Longitude'][msk],
                                        disp=data['DisplayName'][msk], metric=data['MetricName'][msk],
                                        name=data['OrganisationName'][msk],
                                        value=data['Value'][msk])
    all = ColumnDataSource(all)

    # create figure
    bk.output_file("MetricsMap.html", mode="cdn")
    fig = GMapPlot(plot_width=800, plot_height=700, logo=None,
                 x_range=Range1d(), y_range=Range1d(),
                 map_options=GMapOptions(lat=53.4808, lng=-1.2426, zoom=7),
                 api_key='AIzaSyBQH3HGn6tpIrGxekGGRAVh-hISYAPsM78')
    fig.map_options.map_type = "roadmap"
    fig.title.text = "Performance Metrics"

    # hovering information
    hover = HoverTool(tooltips=[("Name", "@name"),
                                ("Metrics", "@metric"),
                                ("Value", "@value")])

    # add tools
    fig.add_tools(PanTool(), BoxZoomTool(), WheelZoomTool(), hover)

    # add data
    circle = Circle(x="lon", y="lat", size=5, fill_color="blue",
                    fill_alpha=0.8, line_color=None)
    fig.add_glyph(source, circle)

    # create callback
    callback = CustomJS(args=dict(source=source), code="""
        var f = cb_obj.get('value');
        var d = all.get('data')[f];

        source.set('data', d);
        source.trigger('change');
        """)
    callback.args["source"] = source
    callback.args["all"] = all
    # Set up widgets
    select = Select(title="Select", value=ops[0], options=ops, callback=callback)

    # show the map
    bk.show(row(select, fig))
开发者ID:saniemi,项目名称:SamPy,代码行数:59,代码来源:metrics.py

示例7: drawMap

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def drawMap(title, datas):
    """
    color : [(lat, lon)]
    """ 
    lat = []
    lon = []
    c = []
    
    for color in datas:
        c_lat, c_lon = zip(*datas[color])
        #print (c_lat)
        lat.extend(map(float, c_lat))
        lon.extend(map(float, c_lon))
        c.extend([color]*len(datas[color]))
        
    center_lat = np.median(lat)
    center_lon = np.median(lon)

    x_range = Range1d()
    y_range = Range1d()
    
    source = ColumnDataSource(
        data=dict(
            lat=lat,
            lon=lon,
            fill=c
        )
    )

    map_options = GMapOptions(lat=center_lat, lng=center_lon, map_type="roadmap", zoom=11)
    plot = GMapPlot(
        x_range=x_range, y_range=y_range,
        map_options=map_options,
        title=title
    )

    # Glyphs (dots on graph)
    circle = Circle(x="lon", y="lat", size=6, line_width=0, fill_color="fill", fill_alpha=0.5, line_alpha=0.0)
    plot.add_glyph(source, circle)

    #Navigation
    pan = PanTool()
    wheel_zoom = WheelZoomTool()
    box_select = BoxSelectTool()

    plot.add_tools(pan, wheel_zoom, box_select)
    overlay = BoxSelectionOverlay(tool=box_select)
    plot.add_layout(overlay)

    return display.HTML(file_html(plot, INLINE, "Google Maps Example"))
开发者ID:alonbar,项目名称:RoadBody,代码行数:52,代码来源:gmaps.py

示例8: create_village_map

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def create_village_map(survey):
    s = survey[["village_name", "_gps_point_latitude" , "_gps_point_longitude"]]
    g = s.groupby("village_name")
    mean = g.agg([np.mean])
    mean = mean.reset_index()
    mean.columns = ['_'.join(col).strip() for col in mean.columns.values]
    mean.columns = ['vn', 'lat_mean', 'lon_mean']
    x_range = Range1d()
    y_range = Range1d()
    map_options = GMapOptions(lat= -2.588, lng=140.5170, zoom=11)
    plot = GMapPlot(
        x_range = x_range,
        y_range = y_range,
        map_options=map_options,
        title = "Lake Sentani"
    )
    dot_source = ColumnDataSource(
        data=dict(
            lat = [float(x) for x in survey['_gps_point_latitude']],
            lon = [float(y) for y in survey['_gps_point_longitude']],
            uuid = [str(x) for x in survey['_uuid']],
            vName = [str(x) for x in survey['village_name']],
            size = [.0001 for x in survey['_uuid']],
        )
    )
    plot.map_options.map_type="terrain"
    circle = Circle(x='lon', y='lat', radius='size', fill_color = 'red', fill_alpha = 0.9)
    plot.add_glyph(dot_source, circle)
    text_source = ColumnDataSource(
        data=dict(
            vn = [str(x) for x in mean['vn']],
            lat = [float(x) for x in mean['lat_mean']],
            lon = [float(x) for x in mean['lon_mean']]
        )
    )
    text = Text(x="lon", y="lat", text="vn", text_color="maroon")
    plot.add_glyph(text_source, text)
    reset = ResetTool()
    pan = PanTool()
    wheel_zoom = WheelZoomTool()
    box_zoom = BoxZoomTool()

    plot.add_tools(pan, wheel_zoom, box_zoom, reset)

    xaxis = LinearAxis(axis_label="lon.", major_tick_in=0)
    plot.add_layout(xaxis, 'below')
    yaxis = LinearAxis(axis_label="lat.", major_tick_in=0)
    plot.add_layout(yaxis, 'left')
    return plot
开发者ID:seansmckinley,项目名称:sentani-codebook,代码行数:51,代码来源:sentani_temp.py

示例9: generate_heatmap

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def generate_heatmap():
    #take date range from user input
    start_date_range = datetime.datetime.strptime(request.form['start_date'],
                                                  "%Y-%m-%d").date()
    end_date_range = datetime.datetime.strptime(request.form['stop_date'],
                                                "%Y-%m-%d").date()

    #calls method to get Pandas data frame within given date range.
    #df = get_dataframe(start_date_range, end_date_range)

    #reads the data frame and stores the latitudes and longitudes for the
    #start stations and the end stations
    start_lats = pd.Series(df_init['start_station_latitude']).unique()
    start_long = pd.Series(df_init['start_station_longitude']).unique()

    small_occurrences = []
    occurrences = df_init['start_station_latitude'].value_counts(sort=False)
    print len(occurrences)
    minimum = min(occurrences)

    #scaling to ensure 'blobs' will always be viewable on the map of NYC
    for o in occurrences:
        o /= (minimum * 2)
        small_occurrences.append(o)

    #Maps out an area of NYC based on the coordinates. Zoom=12 giving issue
    map_options = GMapOptions(lat=40.741557, lng=-73.990467, map_type="roadmap", zoom=11)

    #set the data to displayed on the map: latitudes, longitudes and occurences
    plot = GMapPlot(
        x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options, title="NYC Baby"
    )
    source = ColumnDataSource(
        data=dict(
            lat=start_lats,
            lon=start_long,
            sizes=small_occurrences,
        ))

    #choose the type of shape to plot, size is set to the number of occurrences
    circle = Circle(x="lon", y="lat", size='sizes', fill_color="blue", fill_alpha=1.8, line_color=None)

    #adding the plot and tools to the plot
    plot.add_glyph(source, circle)
    plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool())

    #return to the template
    scriptb, divb = components(plot)
    return render_template('heatmap.html', d1=start_date_range, d2=end_date_range, scriptb=scriptb, divb=divb)
开发者ID:StepOBs,项目名称:NewYorkCitiBikeData,代码行数:51,代码来源:heatmap.py

示例10: trail_map

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def trail_map(data):
    lon = (min(data.lon) + max(data.lon)) / 2
    lat = (min(data.lat) + max(data.lat)) / 2

    map_options = GMapOptions(lng=lon, lat=lat, zoom=13)
    plot = GMapPlot(title="%s - Trail Map" % title, map_options=map_options, plot_width=800, plot_height=800)
    plot.x_range = DataRange1d()
    plot.y_range = DataRange1d()
    plot.add_tools(PanTool(), WheelZoomTool(), ResetTool())

    line_source = ColumnDataSource(dict(x=data.lon, y=data.lat, dist=data.dist))
    line = Line(x="x", y="y", line_color="blue", line_width=2)
    plot.add_glyph(line_source, line)

    return plot
开发者ID:chakas,项目名称:bokeh,代码行数:17,代码来源:trail.py

示例11: getHTML

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
    def getHTML(self, params):
        df = self.getData(params)
        df.columns = ['lat','lon','value']
        x_range = Range1d()
        y_range = Range1d()
        map_options = GMapOptions(lat=39.0, lng=-98.0, map_type="roadmap", zoom=5, styles="""
            [{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"on"},{"lightness":33}]},
            {"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2e5d4"}]},
            {"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#c5dac6"}]},
            {"featureType":"poi.park","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":20}]},
            {"featureType":"road","elementType":"all","stylers":[{"lightness":20}]},
            {"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#c5c6c6"}]},
            {"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#e4d7c6"}]},
            {"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#fbfaf7"}]},
            {"featureType":"water","elementType":"all","stylers":[{"visibility":"on"},{"color":"#acbcc9"}]}]
            """)

        pallete = ['#c1f1fe', '#85e3fd', '#5fd7f9', '#41b6fb', '#4254ff']

        lats, lons = df['lat'].values, df['lon'].values
        bucket = (max(df['value']) - min(df['value'])) / 5
        color_map = (df['value'] - min(df['value'])).apply(lambda x: min(int(x / bucket), 4)).tolist()
        colors = [pallete[x] for x in color_map]
        plot = GMapPlot(
            x_range=x_range, y_range=y_range,
            map_options=map_options,
            title="Historical Weather",
            plot_width=1350,
            plot_height=800
        )
        weather_source = ColumnDataSource(
            data=dict(
                lat=lats,
                lon=lons,
                fill=colors
            )
        )
        weather_circle = Circle(x="lon", y="lat", size=6, fill_color="fill", line_color=None, fill_alpha=0.2)
        plot.add_glyph(weather_source, weather_circle)
        pan = PanTool()
        wheel_zoom = WheelZoomTool()
        box_select = BoxSelectTool()
        # hover = HoverTool()
        plot.add_tools(pan, wheel_zoom, box_select)

        script, div = components(plot, CDN)
        html = "%s\n%s" % (script, div)
        return html
开发者ID:michalmonselise,项目名称:PyData-Talk,代码行数:50,代码来源:spyre_hist_weather.py

示例12: getHTML

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
    def getHTML(self,params):
        df = self.getData(params)
        self.graph_type = params['graph_type']
        df = df.ix[df['hot'] > self.graph_type,:]
        x_range = Range1d()
        y_range = Range1d()
        map_options = GMapOptions(lat=39.0, lng=-98.0, map_type="roadmap", zoom=5, styles="""
            [{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"on"},{"lightness":33}]},
            {"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2e5d4"}]},
            {"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#c5dac6"}]},
            {"featureType":"poi.park","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":20}]},
            {"featureType":"road","elementType":"all","stylers":[{"lightness":20}]},
            {"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#c5c6c6"}]},
            {"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#e4d7c6"}]},
            {"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#fbfaf7"}]},
            {"featureType":"water","elementType":"all","stylers":[{"visibility":"on"},{"color":"#acbcc9"}]}]
            """)

        lats, lons = df['lat'].values, df['lon'].values
        plot = GMapPlot(
            x_range=x_range, y_range=y_range,
            map_options=map_options,
            title="Historical Weather",
            plot_width=1350,
            plot_height=800
            )
        weather_source = ColumnDataSource(
            data=dict(
                lat=lats,
                lon=lons,
                fill=['purple']*len(lats)
                )
            )
        weather_circle = Circle(x="lon", y="lat", size=6, fill_color="fill", line_color=None, fill_alpha=0.2)
        plot.add_glyph(weather_source, weather_circle)
        pan = PanTool()
        wheel_zoom = WheelZoomTool()
        box_select = BoxSelectTool()
        # hover = HoverTool()
        plot.add_tools(pan, wheel_zoom, box_select)

        script, div = components(plot, CDN)
        html = "%s\n%s"%(script, div)
        return html
开发者ID:michalmonselise,项目名称:PyData-Talk,代码行数:46,代码来源:spyre_weather_sd.py

示例13: trail_map

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def trail_map(data):
    lon = (min(data.lon) + max(data.lon)) / 2
    lat = (min(data.lat) + max(data.lat)) / 2

    map_options = GMapOptions(lng=lon, lat=lat, zoom=13)
    plot = GMapPlot(plot_width=800, plot_height=800, map_options=map_options, api_key=API_KEY)
    plot.title.text = "%s - Trail Map" % name
    plot.x_range = Range1d()
    plot.y_range = Range1d()
    plot.add_tools(PanTool(), WheelZoomTool(), ResetTool())

    line_source = ColumnDataSource(dict(x=data.lon, y=data.lat, dist=data.dist))
    line = Line(x="x", y="y", line_color="blue", line_width=2)
    plot.add_glyph(line_source, line)

    if plot.api_key == "GOOGLE_API_KEY":
        plot.add_layout(Label(x=240, y=700, x_units='screen', y_units='screen',
                              text='Replace GOOGLE_API_KEY with your own key',
                              text_color='red'))

    return plot
开发者ID:FourtekIT-incubator,项目名称:bokeh,代码行数:23,代码来源:trail.py

示例14: create_plot

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def create_plot(center_coords,zoom_level = 8):

    x_range = Range1d()
    y_range = Range1d()

    # JSON style string taken from: https://snazzymaps.com/style/1/pale-dawn
    map_options = GMapOptions(lat=center_coords['lat'], lng=center_coords['lng'], map_type="roadmap", zoom=zoom_level, styles="""
    [{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"on"},{"lightness":33}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2e5d4"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#c5dac6"}]},{"featureType":"poi.park","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":20}]},{"featureType":"road","elementType":"all","stylers":[{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#c5c6c6"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#e4d7c6"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#fbfaf7"}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"on"},{"color":"#acbcc9"}]}]
    """)

    plot = GMapPlot(
        x_range=x_range, y_range=y_range,
        map_options=map_options,
        title=u"Тверь"
    )

    pan = PanTool()
    wheel_zoom = WheelZoomTool()
    box_select = BoxSelectTool()

    plot.add_tools(pan, wheel_zoom, box_select)
    return plot
开发者ID:sergeimoiseev,项目名称:othodi,代码行数:24,代码来源:bokeh_gmapm.py

示例15: hpd

# 需要导入模块: from bokeh.models import GMapPlot [as 别名]
# 或者: from bokeh.models.GMapPlot import add_tools [as 别名]
def hpd():
	hpdf = pd.read_csv('hpd.csv')
	print(hpdf.head())
	print(len(hpdf))
	#print(hpdf.long.tolist())
	map_options = GMapOptions(lat=40.80, lng=-73.94, map_type="roadmap", zoom=13, styles="""
[{"featureType":"administrative","elementType":"all","stylers":[{"visibility":"on"},{"lightness":33}]},{"featureType":"landscape","elementType":"all","stylers":[{"color":"#f2e5d4"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#c5dac6"}]},{"featureType":"poi.park","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":20}]},{"featureType":"road","elementType":"all","stylers":[{"lightness":20}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#c5c6c6"}]},{"featureType":"road.arterial","elementType":"geometry","stylers":[{"color":"#e4d7c6"}]},{"featureType":"road.local","elementType":"geometry","stylers":[{"color":"#fbfaf7"}]},{"featureType":"water","elementType":"all","stylers":[{"visibility":"on"},{"color":"#acbcc9"}]}]
""") #do NOT change zoom to 12, map won't load!
	plot = GMapPlot(
	    x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options, plot_width=600, plot_height=750, 
	    api_key=API_KEY #, tools=TOOLS #title=title, tools=[hover]
	)
	source = ColumnDataSource(data=dict(x=[], y=[]))
	source.data = dict(
		x = hpdf.long.tolist(), 
		y = hpdf.lat.tolist()
	)
	circle = Circle(x='x', y='y', size=5, fill_color="orange", fill_alpha=0.2, line_color=None)
	plot.add_glyph(source, circle)
	plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool())#, hover)
	script, div = components(plot)
	return render_template('hpd.html', script=script, div=div)
开发者ID:no140,项目名称:citydata,代码行数:24,代码来源:app_testing.py


注:本文中的bokeh.models.GMapPlot.add_tools方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。