arcgis点击做空间查询并做高亮

view.on('click', (res) => {

// 点击后不知道为什么属性没有查询成功,用的一个圆去做点查询

const circle =new this.$esri.Circle({

center: res.mapPoint,

radius:5,

radiusUnit:'meters'

  })

const query =this.inspectionPointLayer.createQuery()

query.geometry =circle // the point location of the pointer

  // 查询方式

  query.spatialRelationship ='intersects' // this is the default

  query.returnGeometry =true

  // 空间查询

  this.inspectionPointLayer.queryFeatures(query)

.then((response) => {

console.log(response)

// 没有选中元素返回

      if (response.features.length ===0) {

return

      }

// 加高亮/删除高亮,通过保存高亮数据进行删除添加

      view.whenLayerView(that.inspectionPointLayer).then(function (layerView) {

// const data = response.features[0].attributes

        that.currMapData = response.features[0].attributes

        // 判断当前选中是否存在

        if (!that.currHighlight) {

that.currHighlight = layerView.highlight(response.features)

}else {

that.currHighlight.remove()

that.currHighlight = layerView.highlight(response.features)

}

})

})

})

你可能感兴趣的:(arcgis点击做空间查询并做高亮)