findTask.js 1.15 KB
import {loadModules} from 'esri-loader'

export default {

    methods:{
        findByPro(url,layerIds,searchFields,searchText,returnGeometry,callBackFunction){
            loadModules([
                "esri/tasks/FindTask",
                "esri/tasks/support/FindParameters"
            ]).then(([
                         FindTask,
                         FindParameters
                     ]) => {
                var findTask = new FindTask({
                        url:url
                    }),
                    findParameters = new FindParameters();
                findParameters.returnGeometry = returnGeometry ? returnGeometry : false;
                findParameters.layerIds = layerIds;
                findParameters.searchFields = searchFields;
                findParameters.searchText = searchText;
				findParameters.outSpatialReference  = {wkid:3857};
                findTask.execute(findParameters).then(function (result) {
                    if(callBackFunction){
                        callBackFunction(result);
                    }
                });
            }).catch(err => {
                throw (err);
            })

        }

    }
}