A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python-bokeh-plotting-glyphs-over-a-google-map/ below:

Python Bokeh – Plotting glyphs over a Google Map

Python Bokeh – Plotting glyphs over a Google Map

Last Updated : 03 Jul, 2020

Bokeh is a Python interactive data visualization. It renders its plots using HTML and JavaScript. It targets modern web browsers for presentation providing elegant, concise construction of novel graphics with high-performance interactivity. Bokeh can be used to plot glyphs over a Google map. A glyph is a hieroglyphic character or a symbol. To use Google maps in Bokeh, we will use the

gmap()

function of the

plotting

class.

gmap()
Syntax : gmap(parameters) Parameters : Returns : an object of the class GMap

Now let us see how to configure the Google map using the

GMapOptions()

function :

GMapOptions()
Syntax : GMapOptions(parameters) Parameters : Returns : an object of the class GMapOptions
Let us see how to plot glyphs over a Google Map :
  1. Import the required libraries and modules :
  2. Create a file to store our model using output_file().
  3. Configure the Google map using GMapOptions().
  4. Generate a GoogleMap object using gmap().
  5. Determine the coordinates of the glyphs using ColumnDataSource().
  6. Generate the glyphs on the created Google map object.
  7. Display the Google map using show().
Python3 1==
# importing the required modules
from bokeh.plotting import gmap
from bokeh.models import ColumnDataSource, GMapOptions
from bokeh.io import output_file, show

# file to save the model
output_file("gfg.html")

# configuring the Google map
lat = 28.7041
lng = 77.1025
map_type = "hybrid"
zoom = 11
google_map_options = GMapOptions(lat = lat,
                                 lng = lng,
                                 map_type = map_type,
                                 zoom = zoom)

# generating the Google map
google_api_key = ""
title = "Delhi"
google_map = gmap(google_api_key,
                  google_map_options,
                  title = title)

# the coordinates of the glyphs
source = ColumnDataSource(
    data = dict(lat = [28.6, 28.65, 28.7, 28.75, 28.8, 28.85],
                lon = [76.95, 77, 77.05, 77.1, 77.15, 77.25]))

# generating the glyphs on the Google map
x = "lon"
y = "lat"
size = 20
fill_color = "red"
fill_alpha = 1
google_map.square(x = x,
                  y = y,
                  size = size,
                  fill_color = fill_color,
                  fill_alpha = fill_alpha,
                  source = source)

# displaying the model
show(google_map)
Output :

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4