gee-community / qgis-earthengine-plugin

Integrates Google Earth Engine and QGIS using Python API
http://qgis-ee-plugin.appspot.com
MIT License
454 stars 116 forks source link

Map.centerObject() function not accepting Geometry #42

Closed giswqs closed 3 years ago

giswqs commented 4 years ago

It seems the Map.centerObject() function only accepts a FeatureCollection as a parameter. It would be nice if it can also accept a Geometry as a parameter. In this way, it behaves the same way as the JavaScript version.

import ee 
from ee_plugin import Map 

# Create a geodesic polygon.
polygon = ee.Geometry.Polygon([
  [[-5, 40], [65, 40], [65, 60], [-5, 60], [-5, 60]]
])

# Create a planar polygon.
planarPolygon = ee.Geometry(polygon, {}, False)

# polygon = ee.FeatureCollection(polygon)
# planarPolygon = ee.FeatureCollection(planarPolygon)

# Display the polygons by adding them to the map.
Map.centerObject(polygon)
Map.addLayer(polygon, {'color': 'FF0000'}, 'geodesic polygon')
Map.addLayer(planarPolygon, {'color': '000000'}, 'planar polygon')
gena commented 4 years ago

Thanks for testing!

gena commented 4 years ago

The code is being reorganized a bit for the feature info tool. This will be fixed once everything is merged back into master.

gena commented 3 years ago

Should work in the new release