Class Maps

地圖介面集

允許搜尋方向、地理編碼、海拔高度取樣,以及建立靜態地圖圖片。

屬性

屬性類型說明
DirectionFinderDirectionFinderEnums
StaticMapStaticMapEnums

方法

方法傳回類型簡短說明
decodePolyline(polyline)Number[]將編碼後的折線字串解碼回點的陣列中。
encodePolyline(points)String將點的陣列編碼為字串。
newDirectionFinder()DirectionFinder建立新的 DirectionFinder 物件。
newElevationSampler()ElevationSampler建立 ElevationSampler 物件。
newGeocoder()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.
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]);
}

參數

名稱類型說明
polylineString要解碼的編碼折線。

回攻員

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

參數

名稱類型說明
pointsNumber[]要編碼的經緯度組合陣列。

回攻員

String:代表這些點的編碼字串。

另請參閱


newDirectionFinder()

建立新的 DirectionFinder 物件。

回攻員

DirectionFinder:新的路線搜尋器物件。


newElevationSampler()

建立 ElevationSampler 物件。

回攻員

ElevationSampler — 新的高度取樣器物件。


newGeocoder()

建立新的地理編碼器物件。

回攻員

Geocoder:新的地理編碼器物件。


newStaticMap()

建立新的 StaticMap 物件。

回攻員

StaticMap — 新的靜態地圖物件。


setAuthentication(clientId, signingKey)

支援使用外部建立的 Google Maps API 付費方案帳戶,以便運用額外的配額用途。您可以從 Google 企業支援入口網站取得用戶端 ID 和簽署金鑰。將這些值設為 null,即可改回使用預設的配額配額。

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

參數

名稱類型說明
clientIdString用戶端 ID。
signingKeyString私密簽署金鑰。