Reading polygon coordinates

380 views
Skip to first unread message

Dee Mutiibwa

unread,
Mar 13, 2017, 11:53:05 AM3/13/17
to Google App Engine
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

Jordan (Cloud Platform Support)

unread,
Mar 13, 2017, 3:42:08 PM3/13/17
to Google App Engine
Google Groups is meant for general product discussions and not for technical coding questions. 

Since this is a Google Maps API coding issue (and not an App Engine product issue), it is recommended you post your question to the Maps Stack Overflow tag. Be sure to follow the rules to asking good questions and include the actual output you are seeing, along with what you expect to see so that they can properly reproduce and help you.
Reply all
Reply to author
Forward
0 new messages