Thanks to visit codestin.com
Credit goes to github.com

Skip to content

GoogleMapPlotter.plot

frslm edited this page Jun 26, 2020 · 4 revisions

GoogleMapPlotter.plot(lats, lngs, color=None, c=None, **kwargs)


Plot a polyline.

  • Parameters

    • lats [float] – Latitudes.

    • lngs [float] – Longitudes.

  • Optional Parameters

    • color/c/edge_color/ec str – Color of the polyline. Can be hex (‘#00FFFF’), named (‘cyan’), or matplotlib-like (‘c’). Defaults to black.

    • alpha/edge_alpha/ea float – Opacity of the polyline, ranging from 0 to 1. Defaults to 1.0.

    • edge_width/ew int – Width of the polyline, in pixels. Defaults to 1.

    • precision int – Number of digits after the decimal to round to for lat/lng values. Defaults to 6.

Usage:

import gmplot
apikey = '' # (your API key here)
gmap = gmplot.GoogleMapPlotter(37.766956, -122.438481, 13, apikey=apikey)

path = zip(*[
    (37.773097, -122.471789),
    (37.785920, -122.472693),
    (37.787815, -122.472178),
    (37.791430, -122.469763),
    (37.792547, -122.469624),
    (37.800724, -122.469460)
])

gmap.plot(*path, edge_width=7, color='red')
gmap.draw('map.html')

Clone this wiki locally