无法从地图中删除标记(无法读取属性'unselectAll')

时间:2014-05-14 16:53:29

标签: drupal-7 openlayers-3

我正在尝试从地图中删除标记,但我无法使用。我可以选择它,移动它但是当我尝试删除它时它什么也没做。

当我点击删除选项时,会弹出以下js错误:

Uncaught TypeError: Cannot read property 'unselectAll' of undefined openlayers_behavior_geofield.js?n5kot1:39
controls.push.OpenLayers.Control.ModifyFeature.handleKeypress openlayers_behavior_geofield.js?n5kot1:39
OpenLayers.Handler.OpenLayers.Class.callback OpenLayers.js?n5kot1:205
OpenLayers.Handler.Keyboard.OpenLayers.Class.handleKeyEvent OpenLayers.js?n5kot1:647
(anonymous function) OpenLayers.js?n5kot1:63

任何人都知道为什么会发生这种情况?

我正在使用Openlayers 7.x-2.0-beta9和Geofield 7.x-2.1

谢谢!

失败的Geofield文件(openlayers_behavior_geofield.js):

if (options.allow_edit && options.allow_edit !== 0) {
    // add an Edit feature
    controls.push(new OpenLayers.Control.ModifyFeature(layer, {
        deleteCodes: [46, 68, 100],
        handleKeypress: function(evt) {
            if (this.feature && OpenLayers.Util.indexOf(this.deleteCodes, evt.keyCode) > -1) {
                // We must unselect the feature before we delete it
                var feature_to_delete = this.feature;
                this.selectControl.unselectAll();
                this.layer.removeFeatures([feature_to_delete]);
            }
        }
    }));
}

0 个答案:

没有答案