Search code examples
javascriptangulartypescriptopenlayers

Coordinates to wkt OpenLayers


Hello friends, I need to convert the coordinates I received in my project with openlayers to wkt, I would appreciate it if you could help me.

Coordinate information I received:

(2) [32.834075024001905, 39.978537003695095]


Solution

  • have a look at https://openlayers.org/en/latest/apidoc/module-ol_format_WKT.html

    your solution could look like this

    var format = new ol.format.WKT(),
    wkt = format.writeGeometry(yourFeature.getGeometry());