OpenLayers 6 Ошибка при удалении объекта Point - this.featureChangeKeys_ [featureKey] не определено - PullRequest
0 голосов
/ 04 февраля 2020

Я использую OpenLayers 6 с Angular 8 и пытаюсь удалить объекты, нарисованные на карте. Он отлично работает с полигонами, но я пытаюсь удалить точки, я получаю сообщение об ошибке "this.featureChangeKeys_ [featureKey] не определено", исходящее из вектора. js файл.

Мой метод такой, как ниже :

public addInteraction(): void {
     // Defining drawing cursor
     this.modify = new Modify({
        source: this.drawSource,
        features: this.features,
        style: this.drawCursor,
        // the SHIFT key must be pressed to delete vertices, so
        // that new vertices can be drawn at the same position
        // of existing vertices
        deleteCondition: function (event): any {
            return shiftKeyOnly(event) &&
                singleClick(event);
        }
    });
    if (this.drawType !== 'None') {
        if (this.drawType === 'Delete') {
            this.draw = new Select({
                style: this.drawCursor
            });

            this.removeShape();
            this.map.addInteraction(this.draw);
        } else {
            this.draw = new Draw({
                source: this.drawSource,
                type: /** {ol.geom.GeometryType} */ (this.drawType),
            });

            this.map.addInteraction(this.draw);
        }
        this.map.addInteraction(this.modify);
    }
}

removeShape(): any{
    const self = this;
    self.draw.getFeatures().on('add', function (feature: any): any {
        self.drawSource.removeFeature(feature.element); // Error comes here
        feature.target.remove(feature.element);
    });
    return true; 
}

Я провел много исследований, но я не нашел никакого возможного решения этой проблемы.

...