我正在尝试从地图中删除一个标记,但我做不到。我可以选择它,移动它,但是当我尝试删除它时,它什么也没做。
当我单击删除选项时,会弹出以下 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]);
}
}
}));
}