支持方向查找、地理编码、海拔采样和创建静态地图图片。
属性
| 属性 | 类型 | 说明 | 
|---|---|---|
| Direction | Direction | |
| Static | Static | 
方法
| 方法 | 返回类型 | 简介 | 
|---|---|---|
| decode | Number[] | 将编码的多段线字符串解码回点数组。 | 
| encode | String | 将点数组编码为字符串。 | 
| new | Direction | 创建新的 DirectionFinder 对象。 | 
| new | Elevation | 创建 ElevationSampler 对象。 | 
| new | Geocoder | 创建新的 Geocoder 对象。 | 
| new | Static | 创建新的 StaticMap 对象。 | 
| set | void | 允许使用外部建立的 Google Maps API 高级计划账号,以利用额外的配额余额。 | 
详细文档
decode
将编码的多段线字符串解码回点数组。
// Decodes a string representation of the latitudes and longitudes of // Minneapolis and Milwaukee respectively. const polyline = 'qvkpG`qhxPbgyI_zq_@'; const points = Maps.decodePolyline(polyline); for (let i = 0; i < points.length; i += 2) { Logger.log('%s, %s', points[i], points[i + 1]); }
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| polyline | String | 要解码的编码多段线。 | 
返回
Number[] - 纬度经度对的数组(lat0, long0, lat1, long1, ...)。
另请参阅
encode
将点数组编码为字符串。
// The latitudes and longitudes of New York and Boston respectively. const points = [40.77, -73.97, 42.34, -71.04]; const polyline = Maps.encodePolyline(points);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| points | Number[] | 要编码的纬度/经度对数组。 | 
返回
String - 表示这些点的编码字符串。
另请参阅
new
new
new
new
set
允许使用外部建立的 Google Maps API 高级计划账号,以利用额外的配额余额。您可以从 Google 企业支持门户获取客户端 ID 和签名密钥。将这些值设为 null 即可恢复使用默认配额。
Maps.setAuthentication('gme-123456789', 'VhSEZvOXVSdnlxTnpJcUE');
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| client | String | 客户端标识符。 | 
| signing | String | 私钥。 |