Christer
Christer

Reputation: 1681

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.

Upvotes: 4

Views: 7722

Answers (1)

capdragon
capdragon

Reputation: 14899

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]);

Upvotes: 8

Related Questions