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.constpolyline='qvkpG`qhxPbgyI_zq_@';constpoints=Maps.decodePolyline(polyline);for(leti=0;i < points.length;i+=2){Logger.log('%s, %s',points[i],points[i+1]);}
Parameters
Name
Type
Description
polyline
String
An encoded polyline to decode.
Return
Number[] — An array of latitude longitude pairs (lat0, long0, lat1, long1, ...).
Enables the use of an externally established Google Maps APIs Premium Plan 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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-03 UTC."],[[["\u003cp\u003eThe Maps service facilitates tasks such as finding directions, geocoding addresses, sampling elevation data, and generating static map images.\u003c/p\u003e\n"],["\u003cp\u003eIt provides functionalities for encoding and decoding polylines, representing geographical coordinates.\u003c/p\u003e\n"],["\u003cp\u003eYou can create dedicated objects for direction finding, elevation sampling, geocoding, and static map creation.\u003c/p\u003e\n"],["\u003cp\u003eFor users with a Google Maps APIs Premium Plan, authentication can be set to utilize enhanced quota allowances.\u003c/p\u003e\n"]]],[],null,["# Class Maps\n\nMaps\n\nAllows for direction finding, geocoding, elevation sampling and the creation of static map\nimages. \n\n### Properties\n\n| Property | Type | Description |\n|---------------------|----------------------------------------------------------------------------|-------------|\n| `Direction``Finder` | [DirectionFinderEnums](/apps-script/reference/maps/direction-finder-enums) | |\n| `Static``Map` | [StaticMapEnums](/apps-script/reference/maps/static-map-enums) | |\n\n### Methods\n\n| Method | Return type | Brief description |\n|------------------------------------------------------------------------------|-------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [decodePolyline(polyline)](#decodePolyline(String)) | `Number[]` | Decodes an encoded polyline string back into an array of points. |\n| [encodePolyline(points)](#encodePolyline(Number)) | `String` | Encodes an array of points into a string. |\n| [newDirectionFinder()](#newDirectionFinder()) | [DirectionFinder](/apps-script/reference/maps/direction-finder) | Creates a new DirectionFinder object. |\n| [newElevationSampler()](#newElevationSampler()) | [ElevationSampler](/apps-script/reference/maps/elevation-sampler) | Creates an ElevationSampler object. |\n| [newGeocoder()](#newGeocoder()) | [Geocoder](/apps-script/reference/maps/geocoder) | Creates a new Geocoder object. |\n| [newStaticMap()](#newStaticMap()) | [StaticMap](/apps-script/reference/maps/static-map) | Creates a new StaticMap object. |\n| [setAuthentication(clientId, signingKey)](#setAuthentication(String,String)) | `void` | Enables the use of an externally established [Google Maps APIs Premium Plan](https://developers.google.com/maps/premium/) account, to leverage additional [quota allowances](https://developers.google.com/maps/premium/usage-limits). |\n\nDetailed documentation\n----------------------\n\n### `decode``Polyline(polyline)`\n\nDecodes an encoded polyline string back into an array of points.\n\n```javascript\n// Decodes a string representation of the latitudes and longitudes of\n// Minneapolis and Milwaukee respectively.\nconst polyline = 'qvkpG`qhxPbgyI_zq_@';\nconst points = Maps.decodePolyline(polyline);\nfor (let i = 0; i \u003c points.length; i += 2) {\n Logger.log('%s, %s', points[i], points[i + 1]);\n}\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|------------|----------|--------------------------------|\n| `polyline` | `String` | An encoded polyline to decode. |\n\n#### Return\n\n\n`Number[]` --- An array of latitude longitude pairs (lat0, long0, lat1, long1, ...).\n\n#### See also\n\n- [Encoded Polyline Format](/maps/documentation/utilities/polylinealgorithm)\n\n*** ** * ** ***\n\n### `encode``Polyline(points)`\n\nEncodes an array of points into a string.\n\n```javascript\n// The latitudes and longitudes of New York and Boston respectively.\nconst points = [40.77, -73.97, 42.34, -71.04];\nconst polyline = Maps.encodePolyline(points);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|----------|------------|-------------------------------------------------|\n| `points` | `Number[]` | An array of latitude/longitude pairs to encode. |\n\n#### Return\n\n\n`String` --- An encoded string representing those points.\n\n#### See also\n\n- [Encoded Polyline Format](/maps/documentation/utilities/polylinealgorithm)\n\n*** ** * ** ***\n\n### `new``Direction``Finder()`\n\nCreates a new DirectionFinder object.\n\n#### Return\n\n\n[DirectionFinder](/apps-script/reference/maps/direction-finder) --- A new direction finder object.\n\n*** ** * ** ***\n\n### `new``Elevation``Sampler()`\n\nCreates an ElevationSampler object.\n\n#### Return\n\n\n[ElevationSampler](/apps-script/reference/maps/elevation-sampler) --- A new elevation sampler object.\n\n*** ** * ** ***\n\n### `new``Geocoder()`\n\nCreates a new Geocoder object.\n\n#### Return\n\n\n[Geocoder](/apps-script/reference/maps/geocoder) --- A new geocoder object.\n\n*** ** * ** ***\n\n### `new``Static``Map()`\n\nCreates a new StaticMap object.\n\n#### Return\n\n\n[StaticMap](/apps-script/reference/maps/static-map) --- A new static map object.\n\n*** ** * ** ***\n\n### `set``Authentication(clientId, signingKey)`\n\nEnables the use of an externally established [Google Maps APIs Premium Plan](https://developers.google.com/maps/premium/) account,\nto leverage additional [quota\nallowances](https://developers.google.com/maps/premium/usage-limits). Your client ID and signing key can be obtained from the Google Enterprise\nSupport Portal. Set these values to `null` to go back to using the default quota\nallowances.\n\n\n| **Note** : This method doesn't work with API keys. Additionally, please note that Premium Plan is no longer available for new customers. If you don't already have a Premium Plan license, please don't call [setAuthentication(clientId, signingKey)](#setAuthentication(String,String)). You are able to use the [Maps](#) methods with the default quota allowances.\n\n\u003cbr /\u003e\n\n```javascript\nMaps.setAuthentication('gme-123456789', 'VhSEZvOXVSdnlxTnpJcUE');\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|----------------|----------|------------------------|\n| `client``Id` | `String` | A client identifier. |\n| `signing``Key` | `String` | A private signing key. |"]]