允許用於尋找方向、地理編碼、高度取樣及建立靜態地圖圖片。
屬性
屬性 | 類型 | 說明 |
---|---|---|
DirectionFinder | DirectionFinderEnums | |
StaticMap | StaticMapEnums |
方法
方法 | 傳回類型 | 簡短說明 |
---|---|---|
decodePolyline(polyline) | Number[] | 將編碼的折線字串解碼為點陣列。 |
encodePolyline(points) | String | 將點陣列編碼為字串。 |
newDirectionFinder() | DirectionFinder | 建立新的 DirectionFinder 物件。 |
newElevationSampler() | ElevationSampler | 建立 ElevationSampler 物件。 |
newGeocoder() | Geocoder | 建立新的 Geocoding 物件。 |
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. 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]); }
參數
名稱 | 類型 | 說明 |
---|---|---|
polyline | String | 要解碼的編碼折線。 |
Return 鍵
Number[]
— 經緯度座標的陣列 (lat0、long0、lat1、long1、...)。
另請參閱
encodePolyline(points)
將點陣列編碼為字串。
// 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);
參數
名稱 | 類型 | 說明 |
---|---|---|
points | Number[] | 要編碼的經緯度組合的陣列。 |
Return 鍵
String
:表示這些點的編碼字串。
另請參閱
newDirectionFinder()
newElevationSampler()
newGeocoder()
newStaticMap()
setAuthentication(clientId, signingKey)
允許使用外部建立的 Google Maps API 付費方案帳戶,以利用額外的配額配額。您可以透過 Google Enterprise 支援入口網站取得用戶端 ID 和簽署金鑰。請將這些值設為 null
,這樣就能改回使用預設的配額配額。
Maps.setAuthentication('gme-123456789', 'VhSEZvOXVSdnlxTnpJcUE');
參數
名稱 | 類型 | 說明 |
---|---|---|
clientId | String | 用戶端 ID。 |
signingKey | String | 私密簽署金鑰。 |