Earth Engine 将推出
非商业配额层级 ,以保护共享计算资源并确保为所有人提供可靠的性能。所有非商业项目都需要在
2026 年 4 月 27 日 之前选择配额层级,否则系统会默认使用 Community 层级。层级配额将于
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
参数 类型 详细信息 eeObject合集|功能|图片|RawMapId 要添加到地图中的对象。 visParamsFeatureVisualizationParameters|ImageVisualizationParameters,可选 可视化图表参数。对于 Image 和 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' );
发送反馈
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可 获得了许可,并且代码示例已根据 Apache 2.0 许可 获得了许可。有关详情,请参阅 Google 开发者网站政策 。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):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"]],["最后更新时间 (UTC):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"]]