OpenLayers 3 如何从 ol.geom.Point 特征数组创建 ol.geom.Polygon
OpenLayers 3 how can I create an ol.geom.Polygon from an array of ol.geom.Point features
我看到可以传入一个 ol.coordinate 元素数组,但我没有看到一个明显的方法来传入一个 ol.geom.Point 特征数组。从点要素数组创建多边形的最有效方法是什么?
在所有点中循环以收集它们的几何图形,然后从该集合中创建多边形。
var coordinates = [];
points.forEach(function(point) {
coodinates.push(point.getCoordinates());
});
var polygon = new ol.geom.Polygon([coordinates]);
我看到可以传入一个 ol.coordinate 元素数组,但我没有看到一个明显的方法来传入一个 ol.geom.Point 特征数组。从点要素数组创建多边形的最有效方法是什么?
在所有点中循环以收集它们的几何图形,然后从该集合中创建多边形。
var coordinates = [];
points.forEach(function(point) {
coodinates.push(point.getCoordinates());
});
var polygon = new ol.geom.Polygon([coordinates]);