1.引入 "esri/tasks/Geoprocessor"
2.new GP服务,根据提交参数调用gp
const gp =new this.$esri.Geoprocessor({
url: layerUrl.YTH_HYDRODYNAMIC_GP
})
const jobInfo =await gp.submitJob({
input: {
url: ascFileUrl,
format:'.asc'
}
})
3. 关闭组件时停止调用 GP 服务
let flag =true // 避免 GP 服务执行完成后调用 cancelJob 报错
this.$once('hook:beforeDestroy', () => {
flag &&gp.cancelJob(jobInfo.jobId)
})
4. 处理 GP 服务调用结果
const jobInfo2 =await gp.waitForJobCompletion(jobInfo.jobId)
const resultLayer =await gp.getResultMapImageLayer(jobInfo2.jobId)
5.完成GP服务调用,结果图层添加到地图
this.$mapView.map.add(resultLayer,1)
flag =false
6.清除图层
(1)直接添加地图
this.mapView2.map?.removeAll()
(2)添加到地图组layer
const layer =this.cardForecastGroupLayer.findLayerById(this.deleteId)
this.cardForecastGroupLayer.remove(layer)