Announcement: All noncommercial projects registered to use Earth Engine beforeApril 15, 2025 mustverify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.
Map.getBounds Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The
Map.getBounds()method returns the bounds of the current map view.The bounds are returned as a list in the format [west, south, east, north] in degrees by default.
Optionally, the bounds can be returned as GeoJSON by setting the
asGeoJSONargument totrue.The method returns a GeoJSONGeometry, a list of numbers, or a string depending on the
asGeoJSONargument.
| Usage | Returns |
|---|---|
Map.getBounds(asGeoJSON) | GeoJSONGeometry|List<Number>|String |
| Argument | Type | Details |
|---|---|---|
asGeoJSON | Boolean, optional | If true, returns map bounds as GeoJSON. |
Examples
Code Editor (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.vardefaultMap=Map;// ui.Map objects can be constructed. Here, a new map is declared.varnewMap=ui.Map({center:{lat:0,lon:0,zoom:1},style:{position:'bottom-right',width:'400px'}});// Add the newMap to the defaultMap.defaultMap.add(newMap);// You can set the viewport of a ui.Map to be centered on an object.// Here, the defaultMap is centered on a point with a selected zoom level.vargeom=ee.Geometry.Point(-122.0841,37.4223);defaultMap.centerObject(geom,18);defaultMap.addLayer(geom,{color:'orange'},'Googleplex');// Map extent can be fetched using the ui.Map.getBounds method.print('defaultMap bounds as a list',defaultMap.getBounds());print('defaultMap bounds as a dictionary',ee.Dictionary.fromLists(['w','s','e','n'],defaultMap.getBounds()));print('defaultMap bounds as GeoJSON',defaultMap.getBounds({asGeoJSON:true}));// Map center point can be fetched using the ui.Map.getCenter method.print('defaultMap center as a Point geometry',defaultMap.getCenter());// Map zoom level can be fetched using the ui.Map.getZoom method.print('defaultMap zoom level',defaultMap.getZoom());// Map scale can be fetched using the ui.Map.getScale method.print('defaultMap approximate pixel scale',defaultMap.getScale());
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-08 UTC.