1

I am very new to using OpenLayers and new to mapping. I am trying to create a simple map that is getting data from a postgresSQL. The data is then returned into a textarea (Linestring ........). I want to use the result to draw a line on the map.

So far I didn't have any luck making this happen. I can see the returned data from the database using console log.

Any working example/how to using WKT(linestring) OpenLayers 3 will be appreciated.

My HTML
<div class="map" id="map"></div>
<form action="#">
            <div class="mdl-textfield mdl-js-textfield">
                <textarea class="mdl-textfield__input" id="resultTxtArea" readonly rows="30"
                type="text"></textarea> <label class="mdl-textfield__label" for=
                "resultTxtArea">Text lines...</label>
            </div>
</form>

Javascript 2/1 javascript 2/2

Kunle
  • 63
  • 11

1 Answers1

1

Use the readFeature method from ol.format.WKT object (Documentation):

// some example linestring as WKT
var linestringWKT = 'LINESTRING(4 6,7 10)';
// get the feature
var feature = new ol.format.WKT().readFeature(linestringWKT);
Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
Lars
  • 2,315
  • 2
  • 24
  • 29