Get shape data
This article shows you how to get data of shapes that are drawn on the map. We use the drawingManager.getSource() function inside drawing manager. There are various scenarios when you want to extract geojson data of a drawn shape and use it elsewhere.
Get data from drawn shape
The following function gets the drawn shape's source data and outputs it to the screen.
function getDrawnShapes() {
var source = drawingManager.getSource();
document.getElementById('CodeOutput').value = JSON.stringify(source.toJson(), null, ' ');
}
Below is the complete running code sample, where you can draw a shape to test the functionality:
Next steps
Learn how to use additional features of the drawing tools module:
Learn more about the classes and methods used in this article:
Maklum balas
Kirim dan lihat maklum balas untuk