GoogleMapPlotter.polygon

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


Plot a polygon.

  • Parameters

    • lats [float] – Latitudes.

    • lngs [float] – Longitudes.

  • Optional Parameters

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

    • alpha/edge_alpha/ea float – Opacity of the polygon’s edge, ranging from 0 to 1. Defaults to 1.0.

    • edge_width/ew int – Width of the polygon’s edge, in pixels. Defaults to 1.

    • alpha/face_alpha/fa float – Opacity of the polygon’s face, ranging from 0 to 1. Defaults to 0.3.

    • color/c/face_color/fc str – Color of the polygon’s face. Can be hex (‘#00FFFF’), named (‘cyan’), or matplotlib-like (‘c’). Defaults to black.

    • 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.448481, 14, apikey=apikey)

golden_gate_park = zip(*[
    (37.771269, -122.511015),
    (37.773495, -122.464830),
    (37.774797, -122.454538),
    (37.771988, -122.454018),
    (37.773646, -122.440979),
    (37.772742, -122.440797),
    (37.771096, -122.453889),
    (37.768669, -122.453518),
    (37.766227, -122.460213),
    (37.764028, -122.510347)
])

gmap.polygon(*golden_gate_park, face_color='pink', edge_color='cornflowerblue', edge_width=5)
gmap.draw('map.html')