Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WKT and openlayers

I cant find out how to use the WKT format in OpenLayers.

I have tried finding the solution in the documentation, witch bascily brought me to this: http://jsfiddle.net/Christer/WG8YP/2/

But that gives me the error of :

Uncaught SyntaxError: Unexpected number

I have no clue about what the hazzle is about, as the numbers and everything are copied straight out of openlayers own bounds/points/geo.

like image 887
Christer Avatar asked Feb 20 '23 12:02

Christer


1 Answers

Try this

http://jsfiddle.net/WG8YP/4/

addFeatures takes an array of features.

Code:

var polygonFeature = wkt.read("POLYGON((-15.8203125 2.4609375, -15.8203125 -10.546875, 6.85546875 -11.25, 8.26171875 -3.33984375, -15.8203125 2.4609375))");
polygonFeature.geometry.transform(map.displayProjection, map.getProjectionObject());         
vectors.addFeatures([polygonFeature]);
like image 106
capdragon Avatar answered Feb 27 '23 17:02

capdragon