在openlayers 3应用程序中,我能够检索边界范围并适合视图。然而,我现在想通过使用边界范围来创建一个特征/多边形。
let boundingExtent = ol.extent.boundingExtent([[left, bottom], [right, top]]);
//??/let polygon = ol.geom.Polygon.fromExtent(boundingExtent);
var view = this.map.getView();
view.fit(boundingExtent, null);
//let source = this.vectorSource.getSource();
//source.clear();
//feature.setStyle(this.VectorAltStyles);
//source.addFeatures(feature);使用ol.geom.Polygon.fromExtent并将结果添加到向量源似乎不起作用。有没有人能解释一下如何做到这一点?
发布于 2017-09-29 18:36:59
经过多次试验和错误,终于找到了一种方法。
let boundingExtent = ol.extent.boundingExtent([[left, bottom], [right, top]]),
polygon = ol.geom.Polygon.fromExtent(boundingExtent),
feature = new ol.Feature(polygon);
let source = this.vectorSource.getSource();
source.clear();
feature.setStyle(this.VectorStyles);
source.addFeatures([feature]);https://stackoverflow.com/questions/46414184
复制相似问题