WKT和openlayers

时间:2012-08-14 14:22:24

标签: javascript jquery openlayers wkt

我无法了解如何在OpenLayers中使用WKT格式。

我试图找到solution in the documentation,女巫基本上把我带到了这里:http://jsfiddle.net/Christer/WG8YP/2/

但这给了我错误:

Uncaught SyntaxError: Unexpected number

我不清楚hazzle的内容,因为数字和所有内容都是直接从openlayers自己的边界/点/ geo中复制出来的。

1 个答案:

答案 0 :(得分:8)

试试这个

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

addFeatures需要array of features

代码:

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