findTask.js
1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import {loadModules} from 'esri-loader'
export default {
methods:{
/**
* @description: findByPro
* @param {*} url
* @param {*} layerIds
* @param {*} searchFields
* @param {*} searchText
* @param {*} returnGeometry
* @param {*} callBackFunction
* @author: renchao
*/
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);
})
}
}
}