ui.Map.addLayer
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
یک شی EE داده شده را به عنوان یک لایه به نقشه اضافه می کند.
لایه نقشه جدید را برمی گرداند.
استفاده | برمی گرداند | Map. addLayer (eeObject, visParams , name , shown , opacity ) | ui.Map.Layer |
استدلال | تایپ کنید | جزئیات | این: ui.map | ui.Map | نمونه ui.Map. |
eeObject | مجموعه|ویژگی|تصویر|MapId | شیئی که باید به نقشه اضافه شود. |
visParams | FeatureVisualizationParameters|ImageVisualizationParameters، اختیاری | پارامترهای تجسم برای Images و ImageCollection، برای پارامترهای معتبر به ee.data.getMapId مراجعه کنید. برای ویژگیها و مجموعههای ویژگی، تنها کلید پشتیبانیشده «رنگ» است، بهعنوان یک رشته شش نویسهای شش نویسهای در قالب RRGGBB. |
name | رشته، اختیاری | نام لایه. پیشفرض «لایه N» است. |
shown | بولی، اختیاری | پرچمی که نشان می دهد آیا لایه باید به طور پیش فرض روشن باشد یا خیر. |
opacity | شماره، اختیاری | کدورت لایه به صورت عددی بین 0 و 1 نمایش داده می شود. پیش فرض 1 است. |
نمونه ها
ویرایشگر کد (جاوا اسکریپت)
// Define a ui.Map widget and add it to the cleared ui.root.
var map = ui.Map();
ui.root.clear();
ui.root.add(map);
map.setCenter(-121.87, 37.44, 9);
// A Sentinel-2 surface reflectance image.
var image = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');
// 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');
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003e\u003ccode\u003eMap.addLayer()\u003c/code\u003e overlays Earth Engine objects like images and features onto the map as a new layer.\u003c/p\u003e\n"],["\u003cp\u003eVisualization parameters can be customized for images and features, controlling aspects like color, opacity, and stretch.\u003c/p\u003e\n"],["\u003cp\u003eThis function accepts Earth Engine objects (Image, Feature, Geometry, Collections) and styling options to control their visual representation.\u003c/p\u003e\n"],["\u003cp\u003eLayers can be named and controlled for initial visibility.\u003c/p\u003e\n"],["\u003cp\u003eThe function returns the added layer as a \u003ccode\u003eui.Map.Layer\u003c/code\u003e object for further manipulation.\u003c/p\u003e\n"]]],[],null,["# ui.Map.addLayer\n\n\u003cbr /\u003e\n\nAdds a given EE object to the map as a layer.\n\n\u003cbr /\u003e\n\nReturns the new map layer.\n\n| Usage | Returns |\n|------------------------------------------------------------------------------|--------------|\n| Map.addLayer`(eeObject, `*visParams* `, `*name* `, `*shown* `, `*opacity*`)` | ui.Map.Layer |\n\n| Argument | Type | Details |\n|----------------|------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `ui.map` | ui.Map | The ui.Map instance. |\n| `eeObject` | Collection\\|Feature\\|Image\\|MapId | The object to add to the map. |\n| `visParams` | FeatureVisualizationParameters\\|ImageVisualizationParameters, optional | The visualization parameters. For Images and ImageCollection, see ee.data.getMapId for valid parameters. For Features and FeatureCollections, the only supported key is \"color\", as a 6-character hex string in the RRGGBB format. |\n| `name` | String, optional | The name of the layer. Defaults to \"Layer N\". |\n| `shown` | Boolean, optional | A flag indicating whether the layer should be on by default. |\n| `opacity` | Number, optional | The layer's opacity represented as a number between 0 and 1. Defaults to 1. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// Define a ui.Map widget and add it to the cleared ui.root.\nvar map = ui.Map();\nui.root.clear();\nui.root.add(map);\nmap.setCenter(-121.87, 37.44, 9);\n\n// A Sentinel-2 surface reflectance image.\nvar image = ee.Image('COPERNICUS/S2_SR/20210109T185751_20210109T185931_T10SEG');\n\n// Set multi-band RGB image visualization parameters. If the \"bands\" parameter\n// is not defined, the first three bands are used.\nvar rgbVis = {\n bands: ['B11', 'B8', 'B3'],\n min: 0,\n max: 3000\n};\nmap.addLayer(image, rgbVis, 'Multi-band RGB image');\n\n// Set band-specific \"min\" and \"max\" properties.\nvar rgbVisBandSpec = {\n bands: ['B11', 'B8', 'B3'],\n min: [0, 75, 150],\n max: [3500, 3000, 2500]\n};\nmap.addLayer(image, rgbVisBandSpec, 'Band-specific min/max');\n\n// If you don't specify \"min\" and \"max\" properties, they will be determined\n// from the data type range, often resulting in an ineffective color stretch.\nmap.addLayer(image.select('B8'), null, 'Default visParams');\n\n// If an image layer has already been styled, set \"visParams\" as null.\nvar imageRgb = image.visualize(rgbVis);\nmap.addLayer(imageRgb, null, 'Pre-styled image');\n\n// Use the \"palette\" parameter with single-band image inputs to define the\n// linear color gradient to stretch between the \"min\" and \"max\" values.\nvar singleBandVis = {\n min: 0,\n max: 3000,\n palette: ['blue', 'yellow', 'green']\n};\nmap.addLayer(image.select('B8'), singleBandVis, 'Single-band palette');\n\n// Images within ImageCollections are automatically mosaicked according to mask\n// status and image order. The last image in the collection takes priority,\n// invalid pixels are filled by valid pixels in preceding images.\nvar imageCol = ee.ImageCollection('COPERNICUS/S2_SR')\n .filterDate('2021-03-01', '2021-04-01');\nmap.addLayer(imageCol, rgbVis, 'ImageCollection mosaic');\n\n// FeatureCollection, Feature, and Geometry objects can be styled using the\n// \"color\" parameter.\nvar featureCol = ee.FeatureCollection('WCMC/WDPA/current/polygons');\nmap.addLayer(featureCol, {color: 'purple'}, 'FeatureCollection');\n```"]]