arcgis for js 前端GP服务调用

1.先发布好GP服务,例子可参考:https://www.cnblogs.com/hjyjack9563-bk/p/16077788.html,发布好服务后可以看到浏览器如下类似的GP服务

 

2.前端要创建的

Geoprocessor对象

FeatureSet对象作为graphic的集合

注意:传参的参数名要跟服务里的参数名相对应

 

 

 完整代码

复制代码
//GP创建
var gp = new Geoprocessor(url)
      var featureset = new FeatureSet()
// featureset.features = [graphic] featureset.features
= me.initlyr.graphics.items var featureset1 = new FeatureSet() featureset1.features = me.rltfw var para = { 'KQZL': featureset, 'Z_值字段': 'PJZ', '掩膜范围': featureset1, '表达式': "Year = 2019 AND Month = 1 AND TYPE = 'PM2.5'", '重分类区间值': '' // 'cflvals': '0 50 1;50 100 2;100 150 3;150 200 4;200 300 5;300 500 6' } //GP调用 gp.submitJob(para).then(jobinfo => { console.log('gg', jobinfo)
     var status = result.jobStatus;
if(status != esri.tasks.JobInfo.STATUS_SUCCEEDED) return;
// 'output'----对应着服务的参数名 gp.getResultData(jobinfo.jobId, 'output').then(res => { console.log('ggg', res) for (var j in res.value.features) { var item = res.value.features[j] var poly = { type: 'polygon', hasZ: false, hasM: false, rings: item.geometry.rings, spatialReference: view.spatialReference } var tempindex = Number(item.attributes['gridcode']) // var tempindex = Number(item.attributes['grid_code']) - 1 var fillsym = { type: 'simple-fill', // autocasts as new SimpleFillSymbol() color: me.tempColor[tempindex], outline: { // autocasts as new SimpleLineSymbol() color: [255, 255, 0], width: 0 } } var attr = item.attributes attr.type = 'rlt' var gra = new Graphic({ geometry: poly, symbol: fillsym, attributes: attr }) me.rltlyr.add(gra) } view.map.reorder(view.map.findLayerById('界线')) me.loading = false }) })
复制代码

 

posted @   小鱼写代码的过往  阅读(496)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示