【问题标题】:OpenLayers: How to disable the shift key or freehand mode for DrawFeatureOpenLayers:如何禁用 DrawFeature 的 shift 键或手绘模式
【发布时间】:2012-06-05 11:54:52
【问题描述】:

我想禁用 DrawFeature 控件的 shift 键或手绘模式。 典型的代码如下所示:

var drawOptions = {handlerOptions: {freehand: true}};
drawFeatureControl = new OpenLayers.Control.DrawFeature(lineLayer, OpenLayers.Handler.Path, drawOptions);
map.addControl(drawFeatureControl);

可以选择徒手打开。但是没有什么可以完全停用它。 每次我按 shift 时都会使用手绘模式。

在我的用例中,我想将 shift 键用于其他行为。

【问题讨论】:

    标签: controls gis openlayers


    【解决方案1】:

    http://dev.openlayers.org/docs/files/OpenLayers/Handler/Path-js.html#OpenLayers.Handler.Path.freehandToggle

    drawFeatureControl.handler.freehandToggle = null; 可以解决问题。如果您想重新启用它,请将其重置为 'shiftKey'

    【讨论】:

    • 完美!有用。但是现在,当按下 shift 时,来自 OpenLayers.Control.Navigation() 的方块会出现;) 你也知道这个技巧吗?
    • 嗯,类似map.getControlsByClass('OpenLayers.Control.Navigation')[0].zoomBox.deactivate() ?
    • 已确认,“map.getControlsByClass('OpenLayers.Control.Navigation')[0].zoomBox.deactivate()‌​”在 OpenLayers 2.13 中禁用了“Shift-Zoom-Box-feature”。 1
    猜你喜欢
    • 2012-07-21
    • 2014-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-24
    • 1970-01-01
    相关资源
    最近更新 更多