//拖拽要素
    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);
        });
    };

相关文章:

  • 2021-12-31
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
  • 2021-06-30
  • 2020-06-10
  • 2021-10-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2021-07-20
  • 2022-12-23
  • 2022-12-23
  • 2021-06-01
相关资源
相似解决方案