OpenLayers 요소 드래그

1846 단어
    // 
    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);
        });
    };

좋은 웹페이지 즐겨찾기