I've problems with converting the feature which I'm getting in draw interaction into the WKT string. I saw multiple examples which looks like it should be simple but I'm always getting the following exception while calling format.writeGeometry()
function:
Here is my code:
function getDrawInteraction() {
return new ol.interaction.Draw({
source: this.source, //it is ol.source.Vector() for my layer
stopClick: true,
type: "Circle"
});
}
function draw() {
var drawInteraction = getDrawInteraction(),
format = new ol.format.WKT();
drawInteraction.on("drawend", function (event) {
var feature = event.feature,
wkt;
wkt = format.writeGeometry(feature.getGeometry());
});
map.addInteraction(drawInteraction);
}
I'm able to draw a circle on the map but what I am doing wrong WKT string?