0

This is the code I am using for polygon to draw and I am using MapBox GL draw I am trying to get longitude and latitude of every point from polygon.

var draw = new MapboxDraw({
  displayControlsDefault: false,
  controls: {
     polygon: true,
     trash: true,
  }
});

map.addControl(draw);

map.on('draw.create', function(e) { 

    if (lngLat.lng && lngLat.lat == 'polygon') {
        console.log(draw.getAll());
    }
});

1 Answer 1

0

Try this:

var x=draw.getAll();
console.log(x['features'][0]['geometry']['coordinates'][0]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.