我无法了解如何在OpenLayers中使用WKT
格式。
我试图找到solution in the documentation,女巫基本上把我带到了这里:http://jsfiddle.net/Christer/WG8YP/2/
但这给了我错误:
Uncaught SyntaxError: Unexpected number
我不清楚hazzle的内容,因为数字和所有内容都是直接从openlayers自己的边界/点/ geo中复制出来的。
答案 0 :(得分:8)
试试这个
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]);