Annuncio: tutti i progetti non commerciali registrati per l'utilizzo di Earth Engine prima del
15 aprile 2025 devono
verificare l'idoneità non commerciale per mantenere l'accesso a Earth Engine.
Map.add
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Aggiunge un elemento alla mappa. Può essere utilizzato anche per aggiungere widget come ui.Label e alcuni oggetti non widget come ui.Map.Layer.
Restituisce la mappa.
Utilizzo | Resi |
---|
Map.add(item) | ui.Map |
Argomento | Tipo | Dettagli |
---|
item | Oggetto | L'elemento da aggiungere. |
Esempi
Editor di codice (JavaScript)
// The default map in the Code Editor is a built-in ui.Map object called "Map".
// Let's refer to it as "defaultMap" for clarity.
var defaultMap = Map;
// ui.Map objects can be constructed. Here, a new map is declared.
var newMap = ui.Map({
center: {lat: 0, lon: 0, zoom: 1},
style: {position: 'bottom-right', width: '400px'}
});
// Add the newMap to the defaultMap;
defaultMap.add(newMap);
// Other UI widgets can be added to ui.Map objects, for example labels:
defaultMap.add(ui.Label('Default Map', {position: 'bottom-left'}));
newMap.add(ui.Label('New Map', {position: 'bottom-left'}));
// ...selectors:
defaultMap.add(ui.Select(['This', 'That', 'Other']));
// ...or buttons:
defaultMap.add(ui.Button('Click me'));
// You can also add ui.Map.Layer objects. Here, an ee.Geometry object
// is converted to a map layer and added to the default map.
var geom = ee.Geometry.Point(-122.0841, 37.4223);
var geomLayer = ui.Map.Layer(geom, {color: 'orange'}, 'Googleplex');
defaultMap.add(geomLayer);
defaultMap.centerObject(geom, 18);
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-26 UTC.
[null,null,["Ultimo aggiornamento 2025-07-26 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eMap.add()\u003c/code\u003e function adds items like UI widgets (labels, selectors, buttons) and map layers to a ui.Map object.\u003c/p\u003e\n"],["\u003cp\u003eIt accepts an \u003ccode\u003eitem\u003c/code\u003e argument, which can be a UI element or a map layer object, and returns the updated ui.Map object.\u003c/p\u003e\n"],["\u003cp\u003eYou can use this function to add elements to both built-in and custom ui.Map objects for displaying information and interacting with the map.\u003c/p\u003e\n"],["\u003cp\u003eEarth Engine geometries can also be added to the map as layers by first converting them to ui.Map.Layer objects.\u003c/p\u003e\n"]]],[],null,["# Map.add\n\n\u003cbr /\u003e\n\nAdds an item to the map. Can also be used to add widgets like ui.Label as well as some non-widget objects like ui.Map.Layer.\n\n\u003cbr /\u003e\n\nReturns the map.\n\n| Usage | Returns |\n|-----------------|---------|\n| `Map.add(item)` | ui.Map |\n\n| Argument | Type | Details |\n|----------|--------|------------------|\n| `item` | Object | The item to add. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\n// The default map in the Code Editor is a built-in ui.Map object called \"Map\".\n// Let's refer to it as \"defaultMap\" for clarity.\nvar defaultMap = Map;\n\n// ui.Map objects can be constructed. Here, a new map is declared.\nvar newMap = ui.Map({\n center: {lat: 0, lon: 0, zoom: 1},\n style: {position: 'bottom-right', width: '400px'}\n});\n\n// Add the newMap to the defaultMap;\ndefaultMap.add(newMap);\n\n// Other UI widgets can be added to ui.Map objects, for example labels:\ndefaultMap.add(ui.Label('Default Map', {position: 'bottom-left'}));\nnewMap.add(ui.Label('New Map', {position: 'bottom-left'}));\n\n// ...selectors:\ndefaultMap.add(ui.Select(['This', 'That', 'Other']));\n\n// ...or buttons:\ndefaultMap.add(ui.Button('Click me'));\n\n// You can also add ui.Map.Layer objects. Here, an ee.Geometry object\n// is converted to a map layer and added to the default map.\nvar geom = ee.Geometry.Point(-122.0841, 37.4223);\nvar geomLayer = ui.Map.Layer(geom, {color: 'orange'}, 'Googleplex');\ndefaultMap.add(geomLayer);\ndefaultMap.centerObject(geom, 18);\n```"]]