arcgis js 之featureLayer服务查询及筛选
arcgis js 之featureLayer服务查询及筛选
arcgis js中查询前端创建的featureLayer和服务端的featureLayer的查询方式是不同的。
查询服务端featureLayer中的features和extent: (QueryTask)
let queryTask = new QueryTask({ url: mapConfig.areaUrl, spatialReference: { wkid: 3857 } }) queryTask.execute().then(results => { console.log(results.features) this.view.goTo(results.features) })
查询范围:queryTask.executeForExtent()
查询筛选: (Query)
let query = new Query() query.returnGeometry = true query.spatialRelationship = 'intersects' query.outFields = ['*'] query.where = "保护区名称 ='" + obj.label + "'" let queryTask = new QueryTask({ url: mapConfig.areaUrl, spatialReference: { wkid: 3857 } }) queryTask.execute(query).then(results => { console.log(results.extent) })
注意:
1.this.view.goTo() 当作为参数的feature、extent的坐标系错误时,会出现goTo()方法无效的情况
2.arcMap中投影工具转换坐标系
钻研不易,转载请注明出处。。。