Google Apps Script

Maps Service

This service allows scripts to generate static maps, find directions, convert addresses into geocode coordinates, and sample elevations.

Classes

NameBrief description
AvoidAn enum representing the types of restrictions to avoid when finding directions.
ColorAn enum representing the named colors available to use in map images.
DirectionFinderAllows for the retrieval of directions between locations.
DirectionFinderEnumsA collection of enums used by DirectionFinder.
ElevationSamplerAllows for the sampling of elevations at particular locations.
FormatAn enum representing the format of the map image.
GeocoderAllows for the conversion between an address and geographical coordinates.
MapsAllows for direction finding, geocoding, elevation sampling and the creation of static map images.
MarkerSizeAn enum representing the size of a marker added to a map.
ModeAn enum representing the mode of travel to use when finding directions.
StaticMapAllows for the creation and decoration of static map images.
StaticMapEnumsA collection of enums used by StaticMap.
TypeAn enum representing the type of map to render.

Class Avoid

Properties

PropertyTypeDescription
TOLLSEnumAvoid tolls.
HIGHWAYSEnumAvoid highways.

Class Color

Properties

PropertyTypeDescription
BLACKEnum
BROWNEnum
GREENEnum
PURPLEEnum
YELLOWEnum
BLUEEnum
GRAYEnum
ORANGEEnum
REDEnum
WHITEEnum

Class DirectionFinder

Methods

MethodReturn typeBrief description
addWaypoint(latitude, longitude)DirectionFinderAdds a waypoint that the route must pass through, using a point (lat/lng).
addWaypoint(address)DirectionFinderAdds a waypoint that the route must pass through, using an address.
clearWaypoints()DirectionFinderClears the current set of waypoints.
getDirections()ObjectGets the directions using the origin, destination, and other options that were set.
setAlternatives(useAlternatives)DirectionFinderSets whether or not alternative routes should be returned, instead of just the highest ranked route (defaults to false).
setArrive(time)DirectionFinderSets the desired time of arrival (when applicable).
setAvoid(avoid)DirectionFinderSets whether to avoid certain types of restrictions.
setDepart(time)DirectionFinderSets the desired time of departure (when applicable).
setDestination(latitude, longitude)DirectionFinderSets the ending location for which to calculate directions to, using a point (lat/lng).
setDestination(address)DirectionFinderSets the ending location for which to calculate directions to, using an address.
setLanguage(language)DirectionFinderSets the language to be used for the directions.
setMode(mode)DirectionFinderSets the mode of travel (defaults to driving).
setOptimizeWaypoints(optimizeOrder)DirectionFinderSets whether or not to optimize the provided route by rearranging the waypoints in a more efficient order (defaults to false).
setOrigin(latitude, longitude)DirectionFinderSets the starting location from which to calculate directions, using a point (lat/lng).
setOrigin(address)DirectionFinderSets the starting location from which to calculate directions, using an address.
setRegion(region)DirectionFinderSets a region to use when interpreting location names.

Class DirectionFinderEnums

Properties

PropertyTypeDescription
AvoidAvoid
ModeMode

Class ElevationSampler

Methods

MethodReturn typeBrief description
sampleLocation(latitude, longitude)ObjectReturns elevation data for a single point (lat/lng).
sampleLocations(points)ObjectReturns elevation data for a series of points (lat/lng).
sampleLocations(encodedPolyline)ObjectReturns elevation data for the points in an encoded polyline.
samplePath(points, numSamples)ObjectReturns elevation data for a number of samples along a line, defined using a series of points.
samplePath(encodedPolyline, numSamples)ObjectReturns elevation data for a number of samples along a line, defined using an encoded polyline.

Class Format

Properties

PropertyTypeDescription
PNGEnum8-bit PNG format.
PNG8Enum8-bit PNG format.
PNG32Enum32-bit PNG format.
GIFEnumGIF format.
JPGEnumJPEG format.
JPG_BASELINEEnumNon-progressive JPEG format.

Class Geocoder

Methods

MethodReturn typeBrief description
geocode(address)ObjectGets the approximate geographic points for a given address.
reverseGeocode(latitude, longitude)ObjectGets the approximate addresses for a given geographic point.
reverseGeocode(swLatitude, swLongitude, neLatitude, neLongitude)ObjectGets the approximate addresses for a given area.
setBounds(swLatitude, swLongitude, neLatitude, neLongitude)GeocoderSets the bounds of an area that should be given extra preference in the results.
setLanguage(language)GeocoderSets the language to be used in the results.
setRegion(region)GeocoderSets a region to use when interpreting location names.

Class Maps

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.

Class MarkerSize

Properties

PropertyTypeDescription
TINYEnumTiny sized markets (smallest available).
MIDEnumMedium sized markers (largest available).
SMALLEnumSmall sized markers.

Class Mode

Properties

PropertyTypeDescription
DRIVINGEnumDriving directions via roads.
WALKINGEnumWalking directions via pedestrian paths and sidewalks (where available).
BICYCLINGEnumBicycling directions via bicycle paths and preferred streets (where available).
TRANSITEnumTransit directions via public transit routes (where available).

Class StaticMap

Methods

MethodReturn typeBrief description
addAddress(address)StaticMapAdds a new address to the current path definition.
addMarker(latitude, longitude)StaticMapAdds a marker to the map using a point (lat/lng).
addMarker(address)StaticMapAdds a marker to the map using an address.
addPath(points)StaticMapAdds a path to the map using an array of points.
addPath(polyline)StaticMapAdds a path to the map using an encoded polyline.
addPoint(latitude, longitude)StaticMapAdds a new point (lat/lng) to the current path definition.
addVisible(latitude, longitude)StaticMapAdds a point (lat/lng) location that must be visible in the map.
addVisible(address)StaticMapAdds an address location that must be visible in the map.
beginPath()StaticMapStarts a new path definition.
clearMarkers()StaticMapClears the current set of markers.
clearPaths()StaticMapClear the current set of paths.
clearVisibles()StaticMapClears the current set of visible locations.
endPath()StaticMapCompletes a path definition started with beginPath().
getAs(contentType)BlobReturn the data inside this object as a blob converted to the specified content type.
getBlob()BlobGets the image data as a Blob.
getMapImage()Byte[]Gets the raw image data as a byte array.
getMapUrl()StringGets the URL of the map image.
setCenter(latitude, longitude)StaticMapSets the center of the map using a point (lat/lng).
setCenter(address)StaticMapSets the center of the map using an address.
setCustomMarkerStyle(imageUrl, useShadow)StaticMapSets the custom marker image to use when creating new markers.
setFormat(format)StaticMapSets the format of the map image.
setLanguage(language)StaticMapSets the language to be used for text on the map (where avaialbe).
setMapType(mapType)StaticMapSets the type of map to be shown.
setMarkerStyle(size, color, label)StaticMapSets the marker style to use when creating new markers.
setMobile(useMobileTiles)StaticMapSets whether or not to use specialized tile sets for mobile devices.
setPathStyle(weight, color, fillColor)StaticMapSets the path style to use when creating new paths.
setSize(width, height)StaticMapSets the width and height of the map image in pixels.
setZoom(zoom)StaticMapSets the zoom factor, or magnification level, used for the map.

Class StaticMapEnums

Properties

PropertyTypeDescription
ColorColor
FormatFormat
MarkerSizeMarkerSize
TypeType

Class Type

Properties

PropertyTypeDescription
ROADMAPEnumA standard roadmap, as is normally shown on the Google Maps website.
SATELLITEEnumA satellite map.
TERRAINEnumA physical relief map, showing terrain and vegetation.
HYBRIDEnumA hybrid of the satellite and roadmap maps, showing a transparent layer of major streets and place names on the satellite map.

Authentication required

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

Signing you in...

Google Developers needs your permission to do that.