FeatureLayer 介面
google.maps.FeatureLayer
介面
這個介面代表地圖圖層,其中包含特定 FeatureType 的地圖項目,其樣式可在用戶端覆寫,或附加事件。
屬性 | |
|---|---|
featureType |
類型:
FeatureType與這個 FeatureLayer相關聯的FeatureType。 |
isAvailable |
類型:
boolean這個 FeatureLayer 是否可用,也就是這張地圖是否可使用資料導向樣式 (在 Google Cloud 控制台地圖樣式中,有地圖 ID 使用向量圖塊,且已啟用這個 FeatureLayer)。如果這個值為 false (或變成 false),這個 FeatureLayer 的樣式會恢復為預設值,且不會觸發事件。 |
選填 |
類型:
string optional這個 FeatureLayer 的資料集 ID。只有在 featureType 為 FeatureType.DATASET 時才會顯示。 |
style
選填 |
類型:
FeatureStyleOptions|FeatureStyleFunction optionalFeatureLayer中的 Feature 樣式。設定樣式後,系統就會套用樣式。如果樣式函式有更新,請務必再次設定樣式屬性。FeatureStyleFunction 套用至地圖圖塊時,必須傳回一致的結果,且應經過最佳化調整,以提升效能。不支援非同步函式。如果使用 FeatureStyleOptions,該圖層的所有地圖項目都會採用相同的 FeatureStyleOptions 樣式。將樣式設為 null,即可移除先前設定的樣式。如果這個 FeatureLayer 無法使用,設定樣式就不會執行任何操作,並會記錄錯誤。 |
方法 | |
|---|---|
addListener |
addListener(eventName, handler)參數:
傳回值:
MapsEventListener 產生的事件監聽器。將指定的事件監聽器函式新增至指定的事件名稱。傳回這個事件監聽器的 ID,可與 event.removeListener 搭配使用。 |
事件 | |
|---|---|
click |
function(event)引數:
使用者點選 FeatureLayer時,系統會觸發這個事件。 |
mousemove |
function(event)引數:
當使用者的滑鼠移到 FeatureLayer 上時,系統會觸發這個事件。 |
FeatureType 常數
google.maps.FeatureType
constants
程式庫"maps"
特徵類型的 ID。
這些常數也可以做為字串使用。在 TypeScript 中,字串常值是由 FeatureTypeString 類型定義。
const {FeatureType} = await google.maps.importLibrary("maps");
常數 | |
|---|---|
ADMINISTRATIVE_AREA_LEVEL_1 |
表示國家/地區層級底下的第一順位行政實體。 |
ADMINISTRATIVE_AREA_LEVEL_2 |
表示國家/地區層級底下的第二順位行政實體。 |
COUNTRY |
表示國家政治實體。 |
|
表示第三方資料集。 |
LOCALITY |
表示自治城市或鄉鎮的政治實體。 |
POSTAL_CODE |
表示國家/地區郵政地址所使用的郵遞區號。包含郵遞區號。 |
SCHOOL_DISTRICT |
表示學區。 |
FeatureStyleFunction typedef
google.maps.FeatureStyleFunction
typedef
用於設定 FeatureLayer 樣式的函式。
function(FeatureStyleFunctionOptions): (FeatureStyleOptions optional)
FeatureStyleFunctionOptions 介面
google.maps.FeatureStyleFunctionOptions
介面
傳遞至 FeatureStyleFunction 的選項。
屬性 | |
|---|---|
feature |
類型:
FeatureFeature 傳入 FeatureStyleFunction 進行樣式設定。 |
FeatureStyleOptions 介面
google.maps.FeatureStyleOptions
介面
這些選項會指定地圖上 Feature 樣式的修改方式。
屬性 | |
|---|---|
fillColor
選填 |
類型:
string optional十六進位 RGB 字串 (例如綠色為「#00FF00」)。僅適用於多邊形幾何圖形。 |
fillOpacity
選填 |
類型:
number optional填滿不透明度,範圍介於 0.0 和 1.0 之間。僅適用於多邊形幾何圖形。 |
strokeColor
選填 |
類型:
string optional十六進位 RGB 字串 (例如綠色為「#00FF00」)。 |
strokeOpacity
選填 |
類型:
number optional筆劃不透明度,範圍介於 0.0 和 1.0 之間。僅適用於線和多邊形幾何圖形。 |
strokeWeight
選填 |
類型:
number optional筆劃寬度 (以像素為單位)。僅適用於線和多邊形幾何圖形。 |
Feature 介面
google.maps.Feature
介面
代表向量地圖圖塊地圖項目的介面。這些是 FeatureStyleFunction 的輸入內容。請勿儲存特定 Feature 物件的參照,因為參照不會穩定。
屬性 | |
|---|---|
featureType |
類型:
FeatureType這個 Feature的FeatureType。 |
PlaceFeature 介面
google.maps.PlaceFeature
interface
extends Feature
這個介面代表具有地點 ID 的地圖項目,包括 FeatureType.ADMINISTRATIVE_AREA_LEVEL_1、FeatureType.ADMINISTRATIVE_AREA_LEVEL_2、FeatureType.COUNTRY、FeatureType.LOCALITY、FeatureType.POSTAL_CODE 和 FeatureType.SCHOOL_DISTRICT 類型的地圖項目。
屬性 | |
|---|---|
placeId |
類型:
string |
沿用:
featureType
| |
方法 | |
|---|---|
fetchPlace |
fetchPlace()參數:無
擷取這個 PlaceFeature 的 Place。在產生的 Place 物件中,系統會填入 id 和 displayName 屬性。顯示名稱會以使用者在地圖上看到的語言顯示。(之後可透過 Place.fetchFields() 要求其他欄位,但須遵守 Places API 的一般啟用和計費規定)。請勿從 FeatureStyleFunction 呼叫此函式,因為系統僅支援同步 FeatureStyleFunction。如果擷取 Place 時發生錯誤,系統會拒絕承諾。 |
DatasetFeature 介面
google.maps.DatasetFeature
interface
extends Feature
代表資料集特徵的介面。DatasetFeature 的 featureType 一律為 FeatureType.DATASET。
屬性 | |
|---|---|
datasetAttributes |
類型:
Object<string, string>地圖項目屬性的鍵/值對應。 |
datasetId |
類型:
string這項特徵所屬資料集的 ID。 |
沿用:
featureType
| |
FeatureMouseEvent 介面
google.maps.FeatureMouseEvent
interface
extends MapMouseEvent
這個物件是從 FeatureLayer 上的滑鼠事件傳回。
屬性 | |
|---|---|
features |
這個滑鼠事件的 Feature。 |
繼承:
domEvent、latLng | |
方法 | |
|---|---|
沿用:
stop
|