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) // '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 }) })
标签:me,features,item,GP,js,arcgis,var,new 来源: https://www.cnblogs.com/hjyjack9563-bk/p/16080549.html