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>
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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.