Class Maps

Google 地图

支持方向查找、地理编码、海拔采样和创建静态地图图片。

属性

属性类型说明
DirectionFinderDirectionFinderEnums
StaticMapStaticMapEnums

方法

方法返回类型简介
decodePolyline(polyline)Number[]将编码的多段线字符串解码回点数组。
encodePolyline(points)String将点数组编码为字符串。
newDirectionFinder()DirectionFinder创建新的 DirectionFinder 对象。
newElevationSampler()ElevationSampler创建 ElevationSampler 对象。
newGeocoder()Geocoder创建新的 Geocoder 对象。
newStaticMap()StaticMap创建新的 StaticMap 对象。
setAuthentication(clientId, signingKey)void允许使用外部建立的 Google Maps API 高级计划账号,以利用额外的配额余额

详细文档

decodePolyline(polyline)

将编码的多段线字符串解码回点数组。

// 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]);
}

参数

名称类型说明
polylineString要解码的编码多段线。

返回

Number[] - 纬度经度对的数组(lat0, long0, lat1, long1, ...)。

另请参阅


encodePolyline(points)

将点数组编码为字符串。

// 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);

参数

名称类型说明
pointsNumber[]要编码的纬度/经度对数组。

返回

String - 表示这些点的编码字符串。

另请参阅


newDirectionFinder()

创建新的 DirectionFinder 对象。

返回

DirectionFinder - 新的方向感知器对象。


newElevationSampler()

创建 ElevationSampler 对象。

返回

ElevationSampler - 新的海拔采样器对象。


newGeocoder()

创建新的 Geocoder 对象。

返回

Geocoder - 一个新的地理编码器对象。


newStaticMap()

创建新的 StaticMap 对象。

返回

StaticMap - 一个新的静态映射对象。


setAuthentication(clientId, signingKey)

允许使用外部建立的 Google Maps API 高级计划账号,以利用额外的配额余额。您可以从 Google 企业支持门户获取客户端 ID 和签名密钥。将这些值设为 null 即可恢复使用默认配额。

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

参数

名称类型说明
clientIdString客户端标识符。
signingKeyString私钥。