相当于服务地址中的query查询
获取图层范围内的数据4.24
import Query from '@arcgis/core/rest/support/Query';
import * as QueryTask from "@arcgis/core/rest/query";//获取图层范围内的数据4.24
_returnFeatureFromWhere(url, where, geo) {const self = thisreturn new Promise((resolve, reject) => {const queryObject = new Query();queryObject.returnGeometry = true;queryObject.outFields = ["*"];queryObject.where = wherequeryObject.geometry = geo ? geo : null;queryObject.outSpatialReference = self.mapView.spatialReferenceQueryTask.executeQueryJSON(url, queryObject).then(response => {resolve(response)}).catch((err) => {console.log("_returnFeatureFromWhere异常:", err);});})
},
获取图层范围内的数据4.18
//以下下代码放到初始化加载
const self = thisrequire(["esri/tasks/QueryTask","esri/tasks/support/Query"], function(QueryTask,Query) {
self.QueryTask = QueryTask
self.Query = Query});//获取图层范围内的数据4.18
_returnFeatureFromWhere(url, where, geo) {const self = thisreturn new Promise((resolve, reject) => {const query = new self.Query();query.returnGeometry = true;query.outFields = ["*"];query.where = wherequery.geometry = geo ? geo : null;query.outSpatialReference = self.mapView.spatialReferenceconst queryTask = new self.QueryTask(url);queryTask.execute(query).then(response => {resolve(response)})})
},
注意新旧版本的Query的变化!!!