可用於尋找路線、地理編碼、高度取樣,以及建立靜態地圖圖片。
屬性
屬性 | 類型 | 說明 |
---|---|---|
Direction | Direction | |
Static | Static |
方法
方法 | 傳回類型 | 簡短說明 |
---|---|---|
decode | Number[] | 將已編碼的折線字串解碼為點陣列。 |
encode | String | 將點陣列編碼為字串。 |
new | Direction | 建立新的 DirectionFinder 物件。 |
new | Elevation | 建立 ElevationSampler 物件。 |
new | Geocoder | 建立新的 Geocoder 物件。 |
new | Static | 建立新的 StaticMap 物件。 |
set | void | 啟用外部建立的 Google 地圖 API 付費方案帳戶,以便利用額外的配額額度。 |
內容詳盡的說明文件
decode Polyline(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]); }
參數
名稱 | 類型 | 說明 |
---|---|---|
polyline | String | 要解碼的已編碼折線。 |
回攻員
Number[]
:經緯度配對陣列 (lat0, long0, lat1, long1, ...)。
另請參閱
encode Polyline(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);
參數
名稱 | 類型 | 說明 |
---|---|---|
points | Number[] | 要編碼的經緯度組合陣列。 |
回攻員
String
:代表這些點的編碼字串。
另請參閱
new Direction Finder()
new Elevation Sampler()
new Geocoder()
new Static Map()
set Authentication(clientId, signingKey)
啟用外部建立的 Google 地圖 API 付費方案帳戶,以便利用額外的配額額度。您可以從 Google 企業支援入口網站取得用戶端 ID 和簽署金鑰。將這些值設為 null
,即可恢復使用預設配額。
Maps.setAuthentication('gme-123456789', 'VhSEZvOXVSdnlxTnpJcUE');
參數
名稱 | 類型 | 說明 |
---|---|---|
client | String | 用戶端 ID。 |
signing | String | 私密簽署金鑰。 |