Earth Engine 即將推出
非商業用途的配額級別 ,以便保護共用運算資源,並確保所有使用者都能享有穩固效能。所有非商業用途的專案都必須在
2026 年 4 月 27 日 前選取配額級別,否則屆時會預設為「社群」級別。在
2026 年 4 月 27 日 ,所有專案 (無論選取級別的日期為何) 的級別配額都會生效。
瞭解詳情 。
Google uses AI technology to translate content into your preferred language. AI translations can contain errors.
提供意見
Map.addLayer
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
將指定的 EE 物件新增至地圖做為圖層。
傳回新的地圖圖層。
用量 傳回 Map.addLayer(eeObject, visParams , name , shown , opacity )ui.Map.Layer
引數 類型 詳細資料 eeObjectCollection|Feature|Image|RawMapId 要新增至地圖的物件。 visParamsFeatureVisualizationParameters|ImageVisualizationParameters,選用 視覺化參數。如為 Images 和 ImageCollection,請參閱 ee.data.getMapId,瞭解有效參數。如果是 Feature 和 FeatureCollection,唯一支援的鍵是「color」,可以是 CSS 3.0 顏色字串,也可以是「RRGGBB」格式的十六進位字串。如果 eeObject 是地圖 ID,系統會忽略此屬性。 name字串 (選用) 圖層名稱。預設值為「Layer N」。 shown布林值 (選填) 指出圖層是否應預設為開啟的標記。 opacity號碼 (選填) 圖層的不透明度,以介於 0 和 1 之間的數字表示。預設值為 1。
範例
程式碼編輯器 (JavaScript)
// A Sentinel-2 surface reflectance image.
var image = ee . Image ( 'COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG' );
Map . setCenter ( - 121.87 , 37.44 , 9 );
// Set multi-band RGB image visualization parameters. If the "bands" parameter
// is not defined, the first three bands are used.
var rgbVis = {
bands : [ 'B11' , 'B8' , 'B3' ],
min : 0 ,
max : 3000
};
Map . addLayer ( image , rgbVis , 'Multi-band RGB image' );
// Set band-specific "min" and "max" properties.
var rgbVisBandSpec = {
bands : [ 'B11' , 'B8' , 'B3' ],
min : [ 0 , 75 , 150 ],
max : [ 3500 , 3000 , 2500 ]
};
Map . addLayer ( image , rgbVisBandSpec , 'Band-specific min/max' );
// If you don't specify "min" and "max" properties, they will be determined
// from the data type range, often resulting in an ineffective color stretch.
Map . addLayer ( image . select ( 'B8' ), null , 'Default visParams' );
// If an image layer has already been styled, set "visParams" as null.
var imageRgb = image . visualize ( rgbVis );
Map . addLayer ( imageRgb , null , 'Pre-styled image' );
// Use the "palette" parameter with single-band image inputs to define the
// linear color gradient to stretch between the "min" and "max" values.
var singleBandVis = {
min : 0 ,
max : 3000 ,
palette : [ 'blue' , 'yellow' , 'green' ]
};
Map . addLayer ( image . select ( 'B8' ), singleBandVis , 'Single-band palette' );
// Images within ImageCollections are automatically mosaicked according to mask
// status and image order. The last image in the collection takes priority,
// invalid pixels are filled by valid pixels in preceding images.
var imageCol = ee . ImageCollection ( 'COPERNICUS/S2_SR' )
. filterDate ( '2021-03-01' , '2021-04-01' );
Map . addLayer ( imageCol , rgbVis , 'ImageCollection mosaic' );
// FeatureCollection, Feature, and Geometry objects can be styled using the
// "color" parameter.
var featureCol = ee . FeatureCollection ( 'WCMC/WDPA/current/polygons' );
Map . addLayer ( featureCol , { color : 'purple' }, 'FeatureCollection' );
提供意見
除非另有註明,否則本頁面中的內容是採用創用 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 (世界標準時間)。"],[],["The `Map.addLayer` function adds an Earth Engine object to a map as a layer, returning the new `ui.Map.Layer`. It accepts an `eeObject` (Collection, Feature, Image, or RawMapId), optional `visParams` for visualization, `name` for the layer's label, `shown` (boolean) to set default visibility, and `opacity` (0-1). Visualization parameters vary by object type; `color` is the only supported parameter for Features, while Images support `bands`, `min`, `max`, and `palette`. ImageCollections are mosaicked, and the last images take precedence.\n"]]