Blame view

src/utils/map/IdentifyUtils.js 1.89 KB
任超 committed
1 2 3 4
import {loadModules} from 'esri-loader'

export default {
    methods: {
yuanbo committed
5 6 7 8 9 10 11 12 13 14 15 16
      /**
       * @description: identify
       * @param {*} url
       * @param {*} layerIds
       * @param {*} geometry
       * @param {*} callBackFunction
       * @param {*} returnGeometry
       * @param {*} layerOption
       * @param {*} tolerance
       * @param {*} mapExtent
       * @author: renchao
       */
任超 committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
        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;
yuanbo committed
33
                }
任超 committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47
                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);
            });
yuanbo committed
48

任超 committed
49 50
        }
    }
yuanbo committed
51
}