Hi GEE,
Am creating an app which uses rectangle, polygon, circle etc to draw of interest on Google Map.
var drawingManager = new google.maps.drawing.DrawingManager({
drawingMode: google.maps.drawing.OverlayType.POLYGON,
drawingControl: true,
drawingControlOptions: {
position: google.maps.ControlPosition.TOP_CENTER,
drawingModes: ['rectangle', 'circle', 'polygon', 'polyline', 'marker']
I created a created a function to unpack the coordinates of the Polygon as
var getCoordinates = function(rect) {
var points = rect.getPath().getArray();
return points.map(function(point){
return [point.lng(), point.lat()];
});
I get the JSON of the coordinates as
$.getJSON(
'/getmapdata',
{
polygon: getCoordinates(polygon),
pickerStartDate: getStartDate(),
pickerEndDate: getEndDate(),
},
At the backend I read the coordinates as:
if self.request.get('polygon'):
coords = [float(i) for i in self.request.get('polygon')]
geometry = ee.FeatureCollection([ee.Feature(
ee.Geometry.Polygon(coords=coords),
{'system:index': '0'}
)])
else:
However the backend script seems not to be reading the coordinates right and is not able creating the geometry. What am I doing wrong at the back end?
thank you for help