【发布时间】:2018-05-15 06:10:51
【问题描述】:
我想添加一个双击事件来删除一个功能。虽然这段代码运行良好,但存在一个问题:地图无法刷新,地图中的要素仍在,直到我双击下一步。我该怎么办?
_createDoubleSelectControl: function() {
var selectedStyle = [
new OpenLayers.style.Style({
stroke: new OpenLayers.style.Stroke({
color: '#3399CC',
width: 1.25
})
})
];
this.doubleClickSelector = new OpenLayers.interaction.Select({
condition: OpenLayers.events.condition.doubleClick,
style: selectedStyle,
multi: true,
layers: [this.layers.cellLayer],
filter: function(feature, layer) {
return layer === this.layers.cellLayer;
}.bind(this)
});
this.map.addInteraction(this.doubleClickSelector);
this.doubleClickSelector.on('select', function(event) {
let features = event.target.getFeatures();
features.forEach(function(feature) {
this._cellLayer.getSource().removeFeature(feature);
//this._cellLayer.refresh();
this._cellLayer.refresh({
force: true,
active: true
});
this.map.removeLayer(this._cellLayer);
this.map.addLayer(this._cellLayer);
}.bind(this));
}.bind(this));
},
【问题讨论】:
标签: javascript openlayers layer