背景
使用了两坐标系不一样的两个图层,一个使用了TileLayer
,另外一个是FeatureLayer
。TileLayer
只是用来展示(充当底图),查询的数据是featureLayer
上的。查出的数据的spatialReference
不一样,无法跳转。
解决
使用投影 esri
中的Projection
getGeometry(geometry, spatialReference) {
return new Promise((resolve) => {
this.esri.Projection.load().then(() => {
const nGeometry = this.esri.Projection.project(geometry, spatialReference)
resolve(nGeometry)
})
})
},
let geometry = graphic.geometry
if (geometry.spatialReference.wkid !== this.view.spatialReference.wkid) {
geometry = await this.getGeometry(geometry, this.view.spatialReference)
}
this.view.goTo({ target: geometry, zoom: 5 }, { duration: 1000 })