Я использую openlayers 5 и angular6.Я получаю некоторые функции векторного слоя, помещаю их в массив объявлений и пытаюсь создать LineString на лету.
Это мой код
import * as Extent from 'ol/extent.js';
import Geometry from 'ol/geom/Geometry.js';
import LineString from 'ol/geom/LineString.js';
extent: Extent;
linestring: LineString;
geometry: Geometry;
итогда функция
let features = this.vectorsource.getFeatures();
let pointsline=[];
features.forEach((item) => {
if ( item.values_.clicked ){
var aa = item.getGeometry().getExtent();
var oo = Extent.getCenter(aa);
pointsline.push('['+oo+']');
}
});
if (pointsline.length > 1) {
this.linestring = new LineString({coordinates:pointsline});
this.clicledRouteFeature = new Feature({
Geometry: this.linestring
});
this.clicledRouteFeature.setStyle(new Style({
stroke: new Stroke({
color: 'red',
width: 22
})
}));
this.vectorsource.addFeatures(this.clicledRouteFeature);
}
Это мочалка, которую я могу сделать.Пожалуйста, помогите мне сделать эту работу.Я получаю сообщение об ошибке
ОШИБКА TypeError: Невозможно прочитать свойство 'длина' из неопределенного
со ссылкой на эту строку:
this.linestring = new LineString({coordinates:pointsline});
Есть предложения?
Спасибо