Pengumuman: Semua project nonkomersial yang terdaftar untuk menggunakan Earth Engine sebelum 15 April 2025 harus memverifikasi kelayakan nonkomersial untuk mempertahankan akses Earth Engine.
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Memusatkan tampilan peta pada objek tertentu.
Menampilkan ui.Map ini.
Penggunaan
Hasil
Map.centerObject(object, zoom, onComplete)
ui.Map
Argumen
Jenis
Detail
ini: ui.map
ui.Map
Instance ui.Map.
object
Elemen|Geometri
Objek yang akan dipusatkan - geometri, gambar, atau fitur.
zoom
Nomor, opsional
Tingkat zoom, dari 0 hingga 24. Jika tidak ditentukan, dihitung berdasarkan kotak pembatas objek.
onComplete
Fungsi, opsional
Callback yang dipicu setelah penyesuaian posisi berhasil diselesaikan. Jika parameter ini diteruskan, operasi
`centerObject` akan berjalan secara asinkron.
[null,null,["Terakhir diperbarui pada 2025-07-26 UTC."],[[["\u003cp\u003e\u003ccode\u003ecenterObject\u003c/code\u003e centers the map view on a provided object (geometry, image, or feature).\u003c/p\u003e\n"],["\u003cp\u003eYou can optionally specify the zoom level and an \u003ccode\u003eonComplete\u003c/code\u003e callback function.\u003c/p\u003e\n"],["\u003cp\u003eLarge or complex objects as input can negatively impact performance.\u003c/p\u003e\n"],["\u003cp\u003eUse the smallest necessary object to achieve the desired centering.\u003c/p\u003e\n"]]],[],null,["# ui.Map.centerObject\n\n\u003cbr /\u003e\n\nCenters the map view on a given object.\n\n\u003cbr /\u003e\n\n| **Caution:** providing a large or complex collection as input can result in poor performance. Collating the geometry of collections does not scale well; use the smallest collection (or geometry) that is required to achieve the desired outcome.\n\nReturns this ui.Map.\n\n| Usage | Returns |\n|-------------------------------------------------------|---------|\n| Map.centerObject`(object, `*zoom* `, `*onComplete*`)` | ui.Map |\n\n| Argument | Type | Details |\n|----------------|--------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| this: `ui.map` | ui.Map | The ui.Map instance. |\n| `object` | Element\\|Geometry | An object to center on - a geometry, image or feature. |\n| `zoom` | Number, optional | The zoom level, from 0 to 24. If unspecified, computed based on the object's bounding box. |\n| `onComplete` | Function, optional | A callback which is triggered after the recentering completes successfully. Passing this parameter causes the \\`centerObject\\` operation to run asynchronously. |\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// You can set the viewport of a ui.Map to be centered on an object.\n// Here, the defaultMap is centered on a point with a selected zoom level.\nvar geom = ee.Geometry.Point(-122.0841, 37.4223);\ndefaultMap.centerObject(geom, 18);\ndefaultMap.addLayer(geom, {color: 'orange'}, 'Googleplex');\n\n// Map extent can be fetched using the ui.Map.getBounds method.\nprint('defaultMap bounds as a list',\n defaultMap.getBounds());\nprint('defaultMap bounds as a dictionary',\n ee.Dictionary.fromLists(['w', 's', 'e', 'n'], defaultMap.getBounds()));\nprint('defaultMap bounds as GeoJSON',\n defaultMap.getBounds({asGeoJSON: true}));\n\n// Map center point can be fetched using the ui.Map.getCenter method.\nprint('defaultMap center as a Point geometry', defaultMap.getCenter());\n\n// Map zoom level can be fetched using the ui.Map.getZoom method.\nprint('defaultMap zoom level', defaultMap.getZoom());\n\n// Map scale can be fetched using the ui.Map.getScale method.\nprint('defaultMap approximate pixel scale', defaultMap.getScale());\n```"]]