IdentifyUtils.js 1.61 KB
import {loadModules} from 'esri-loader'

export default {
    methods: {
     
        identify(url,layerIds,geometry,callBackFunction,returnGeometry,layerOption,tolerance,mapExtent){
            var self = this;
            loadModules([
                "esri/tasks/IdentifyTask",
                "esri/tasks/support/IdentifyParameters"
            ]).then(([
                IdentifyTask,
                                     IdentifyParameters
            ]) => {
                var identifyTask = new IdentifyTask({
                    url:url
                }),
                identifyParameters = new IdentifyParameters();
                identifyParameters.geometry = geometry;
                if(layerIds){
                    identifyParameters.layerIds = layerIds;
                } 
                identifyParameters.layerOption  = layerOption ? layerOption : "all";
                identifyParameters.tolerance = tolerance ? tolerance : 3;
                identifyParameters.mapExtent = mapExtent ? mapExtent : geometry.extent;
                identifyParameters.returnGeometry  = returnGeometry ? returnGeometry : false;
                //identifyParameters.returnFieldName = true;
                identifyParameters.spatialReference = geometry.spatialReference;
                identifyTask.execute(identifyParameters).then(result => {
                    if(callBackFunction && typeof callBackFunction == 'function'){
                        callBackFunction(result);
                    }
                });
            }).catch(err => {
                throw(err);
            });
                       
        }
    }
}