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

Skip to content

GoogleMapPlotter.scatter

frslm edited this page Jun 26, 2020 · 9 revisions

GoogleMapPlotter.scatter(lats, lngs, color=None, size=None, marker=True, c=None, s=None, symbol='o', **kwargs)


Plot a collection of points.

  • Parameters

    • lats [float] – Latitudes.

    • lngs [float] – Longitudes.

  • Optional Parameters

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

    • size/s int or [int] – Size of each point, in meters (symbols only). Defaults to 40.

    • marker bool or [bool] – True to plot points as markers, False to plot them as symbols. Defaults to True.

    • symbol str or [str] – Shape of each point, as ‘o’, ‘x’, or ‘+’ (symbols only). Defaults to ‘o’.

    • title str or [str] – Hover-over title of each point (markers only).

    • label str or [str] – Label displayed on each point (markers only).

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

    • alpha/face_alpha/fa float or [float] – Opacity of each point’s face, ranging from 0 to 1 (symbols only). Defaults to 0.3.

    • alpha/edge_alpha/ea float or [float] – Opacity of each point’s edge, ranging from 0 to 1 (symbols only). Defaults to 1.0.

    • edge_width/ew int or [int] – Width of each point’s edge, in pixels (symbols only). Defaults to 1.

Usage:

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

attractions = zip(*[
    (37.769901, -122.498331),
    (37.768645, -122.475328),
    (37.771478, -122.468677),
    (37.769867, -122.466102),
    (37.767187, -122.467496),
    (37.770104, -122.470436)
])

gmap.scatter(
    *attractions,
    color=['red', 'orange', 'yellow', 'green', 'blue', 'purple'],
    s=60,
    ew=2,
    marker=[True, True, False, True, False, False],
    symbol=[None, None, 'o', None, 'x', '+'],
    title=['First', 'Second', None, 'Third', None, None],
    label=['A', 'B', 'C', 'D', 'E', 'F']
)

gmap.draw('map.html')

Clone this wiki locally