公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取。如未在 2025 年 9 月 26 日前完成驗證,存取權可能會暫停。
ee.FeatureCollection.getMap
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
這個必要函式會傳回地圖 ID 和權杖,適合用於產生地圖疊加層。
傳回可傳遞至 ee.data.getTileUrl 或 ui.Map.addLayer 的物件,包括額外的「image」欄位,其中包含包裝這個 FeatureCollection 的 Collection.draw 圖片。如果指定了回呼,則為未定義。
| 用量 | 傳回 |
|---|
FeatureCollection.getMap(visParams, callback) | MapId|Object |
| 引數 | 類型 | 詳細資料 |
|---|
這個:featurecollection | FeatureCollection | FeatureCollection 執行個體。 |
visParams | 物件 (選用) | 視覺化參數。目前只允許一個參數,即包含 RGB 顏色字串的「color」。如未指定 vis_params,則會使用顏色 #000000。 |
callback | 函式 (選用) | 非同步回呼。如未提供,系統會同步發出呼叫。 |
範例
程式碼編輯器 (JavaScript)
// FeatureCollection of power plants in Belgium.
var fc = ee.FeatureCollection('WRI/GPPD/power_plants')
.filter('country_lg == "Belgium"');
// Get MapId for styled FeatureCollection.
var mapId = fc.getMap({color: '800080'});
print('mapId for styled FeatureCollection', mapId);
// MapId can be used as an input to Map.addLayer to display the layer.
Map.setCenter(4.56, 50.78, 7);
Map.addLayer(mapId);
// MapId can be used as an input to ee.data.getTileUrl to fetch map tiles.
print('URL for zoom level 6 tile that includes majority of points',
ee.data.getTileUrl(mapId, 32, 21, 6));
Python 設定
請參閱
Python 環境頁面,瞭解 Python API 和如何使用 geemap 進行互動式開發。
import ee
import geemap.core as geemap
Colab (Python)
# FeatureCollection of power plants in Belgium.
fc = ee.FeatureCollection('WRI/GPPD/power_plants').filter(
'country_lg == "Belgium"'
)
# Get MapId for styled FeatureCollection.
map_id = fc.getMapId({'color': '800080'})
display('map_id for FeatureCollection', map_id)
# MapId can be used as an input to geemap.Map.add_layer to display the layer.
m = geemap.Map()
m.set_center(4.56, 50.78, 7)
m.add_layer(map_id['image'])
display(m)
# MapId can be used as an input to ee.data.getTileUrl to fetch map tiles.
display(
'URL for zoom level 6 tile that includes majority of points',
ee.data.getTileUrl(map_id, 32, 21, 6),
)
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-26 (世界標準時間)。"],[],[]]