OpenLayers 2:仅用两点绘制路径

时间:2015-05-17 17:18:25

标签: javascript openlayers

我想绘制一条不超过2分的路径。在第二点,我希望路径完成。

任何人都可以帮助我如何在openlayers 2中实现此功能。

我尝试了这段代码,但是虽然很好地创建了行,但它会出错。

        _singleLineControl = new OpenLayers.Control.DrawFeature(
            _singleLineLayer,
            OpenLayers.Handler.Path,
            {
                eventListeners: { "featureadded": drawingFinished },
                callbacks: {
                    point: function (pointGeometry, lineGeometry) {
                        var numPoints = lineGeometry.getVertices().length;
                        if (numPoints == 3) {
                            this.drawFeature(lineGeometry);
                        }
                    }
                }
            });
        viewer.addControl(_singleLineControl);
        _singleLineControl.handler.single = true;
        _singleLineControl.handler.freehand = false;
        _singleLineControl.deactivate();

enter image description here

1 个答案:

答案 0 :(得分:0)

使用Error Loading Stream: Could not connect to server

自己找到了解决方案
maxVertices