//拖拽要素 function dragFeature (_map,_dragEndCallback) { let selFeature = null; _map.on("pointerdrag", function (evt) { selFeature = _map.getFeaturesAtPixel(evt.pixel, function (feature) { return feature; }); }); let translate = new ol.interaction.Translate({//拖拽移动interaction features: selFeature//拖拽的为选择的要素 }); _map.encmap.addInteraction(translate); translate.on('translateend', function (f) { if(_dragEndCallback){ let obj = {}; obj.features=f.features; obj.coordinate=f.coordinate; _dragEndCallback(obj);//拖拽完成事件,可以获取拖拽后的要素 } _map.removeInteraction(translate); }); };