Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-08 UTC."],[[["\u003cp\u003e\u003ccode\u003eMap.getBounds()\u003c/code\u003e returns the current map view's boundaries in degrees as a list: \u003ccode\u003e[west, south, east, north]\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe optional \u003ccode\u003easGeoJSON\u003c/code\u003e argument allows retrieval of bounds in GeoJSON format.\u003c/p\u003e\n"],["\u003cp\u003eThis function is used to programmatically access and utilize the current map view extent within your code.\u003c/p\u003e\n"]]],["The `Map.getBounds()` method retrieves the current map view's boundaries. It returns a list in the format \\[west, south, east, north] by default. If the optional `asGeoJSON` argument is set to true, it returns the bounds as GeoJSON. The code shows examples of using `getBounds()` with both list and GeoJSON outputs, and also how to retrieve other information such as map center, zoom level, and pixel scale.\n"],null,["\u003cbr /\u003e\n\nReturns the bounds of the current map view, as a list in the format \\[west, south, east, north\\] in degrees.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|--------------------------------|-----------------------------------------|\n| `Map.getBounds(`*asGeoJSON*`)` | GeoJSONGeometry\\|List\\\u003cNumber\\\u003e\\|String |\n\n| Argument | Type | Details |\n|-------------|-------------------|-----------------------------------------|\n| `asGeoJSON` | Boolean, optional | If true, returns map bounds as GeoJSON. |\n\nExamples\n\nCode 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```"]]