0

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:

enter image description here

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?

2
  • 1
    WKT (and GeoJSON) doesn't support Circle (it's not a standard geometry type outside of OpenLayers). See gis.stackexchange.com/questions/144617/…
    – Mike
    Commented Sep 17, 2019 at 21:40
  • I'm new to OpenLayers and I didn't know that! It might help me a lot, thanks! Commented Sep 18, 2019 at 6:19

0

Your Answer

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