Google Apps Script

Class Maps

Allows for direction finding, geocoding, elevation sampling and the creation of static map images.

Properties

PropertyTypeDescription
DirectionFinderDirectionFinderEnums
StaticMapStaticMapEnums

Methods

MethodReturn typeBrief description
decodePolyline(polyline)Number[]Decodes an encoded polyline string back into an array of points.
encodePolyline(points)StringEncodes an array of points into a string.
newDirectionFinder()DirectionFinderCreates a new DirectionFinder object.
newElevationSampler()ElevationSamplerCreates an ElevationSampler object.
newGeocoder()GeocoderCreates a new Geocoder object.
newStaticMap()StaticMapCreates a new StaticMap object.
setAuthentication(clientId, signingKey)voidEnables the use of an externally established Maps API for Business account, to leverage additional quota allowances.

Detailed documentation

decodePolyline(polyline)

Decodes an encoded polyline string back into an array of points.

 
// Decodes a string representation of the latitudes and longitudes of Minneapolis and Milwaukee
 // respectively.
 var polyline = 'qvkpG`qhxPbgyI_zq_@';
 var points = Maps.decodePolyline(polyline);
 for (var i = 0; i < points.length; i+= 2) {
   Logger.log('%s, %s', points[i], points[i+1]);
 }
 

Parameters

NameTypeDescription
polylineStringan encoded polyline

Return

Number[] — an array of latitude longitude pairs (lat0, long0, lat1, long1, ...)

See also


encodePolyline(points)

Encodes an array of points into a string.

 
// The latitudes and longitudes of New York and Boston respectively.
 var points = [40.77, -73.97, 42.34, -71.04];
 var polyline = Maps.encodePolyline(points);
 

Parameters

NameTypeDescription
pointsNumber[]an array of latitude/longitude pairs to encode

Return

String — an encoded string

See also


newDirectionFinder()

Creates a new DirectionFinder object.

Return

DirectionFinder — a DirectionFinder object


newElevationSampler()

Creates an ElevationSampler object.

Return

ElevationSampler — an ElevationSampler object


newGeocoder()

Creates a new Geocoder object.

Return

Geocoder — a Geocoder object


newStaticMap()

Creates a new StaticMap object.

Return

StaticMap — a StaticMap object


setAuthentication(clientId, signingKey)

Enables the use of an externally established Maps API for Business account, to leverage additional quota allowances. Your client ID and signing key can be obtained from the Google Enterprise Support Portal. Set these values to null to go back to using the default quota allowances.

 
Maps.setAuthentication('gme-123456789', 'VhSEZvOXVSdnlxTnpJcUE');
 

Parameters

NameTypeDescription
clientIdStringclient identifier
signingKeyStringprivate signing key

See also

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.