ol3重置以在坐标相交时绘制交互模式

时间:2016-11-17 19:31:26

标签: draw openlayers openlayers-3 intersection

this.drawInteraction = new ol.interaction.Draw({ 
        features: this.sourceFeatures,
        type: 'Polygon', 
        geometryFunction: (coords, geom) => this.onDrawGeometryFunction(coords, geom) 
    });

private onDrawGeometryFunction(coords, geom): void {
    if (!geom) {
        geom = new ol.geom.Polygon(null);
    } 
    if (coords[0].length !== this.coords_length) {
        //if intersects undo last point 
        if (this.intersectionsExistInPolygon(coords[0])) { 
            this.drawInteraction.removeLastPoint();
            return geom;
        }
        this.coords_length = coords[0].length;        
    }
     geom.setCoordinates(coords);
    return geom;
}

我能够识别交叉点,直到我点击起点完成绘制(通过绘制线连接)。有没有办法在抽奖结束之前完成抽奖(但不是' drawend')?通过删除相交的最后一点来保持绘制模式处于活动状态。

1 个答案:

答案 0 :(得分:0)

好吧,我使用的是Openlayers@v3.14.2,这个完成条件可以从v3.16.0获得。所以我只需要更新它工作正常的版本..