首页 > 代码库 > GIS有关GP服务的发布和调用

GIS有关GP服务的发布和调用

1、通过Modelbuilder新建工具。(注意:假如工具输出两个以上的结果,需要保存在相同文件及下,并将输入输出都设置为参数)

技术分享

技术分享

 

 

2、调用新建的工具,在result窗口中查看结果,工作是否正确。

3、发布服务时,参数要设置自定义,并且异步调用

技术分享

4、调用参数说明:

技术分享

5、参数输入世必须是字符串格式,json需要用JSON.stringify(obj);进行转换

6、调用时: usr1="https://localhost:6443/arcgis/rest/services/gp服务所在目录/gp服务名/MapServer/jobs/“+data.jobId;

7、范例:

button.onclick = function(){
                    var query = new esri.tasks.Query();
                    query.where = "1=1";
                    query.returnGeometry=true;
                    query.outFields = ["*"];
                    featureLayer.queryFeatures(query, function(ff) {
                        console.log("查询完成");
                        var gpServiceUrl="https://localhost:6443/arcgis/rest/services/gp服务所在目录/gp服务名/GPServer/gp服务名";
                        var gp = new esri.tasks.Geoprocessor(gpServiceUrl);
                        var obj=createObj(ff);
                        var str=JSON.stringify(obj);
                        //设置GP参数  
                          var params = {
                              GDP:str,
                              Field: "GDP"
                          };  
                          gp.submitJob(params, function(data){
                                console.log("complete");
                                console.log(data);
                                var usr1="https://localhost:6443/arcgis/rest/services/gp服务所在目录/gp服务名/MapServer/jobs";
                                var mapurl= usr1+"/"+data.jobId;
                                var hotspotLayer = new esri.layers.ArcGISDynamicMapServiceLayer(mapurl, {  
                                    "id": "bufferlayer"  
                                });
                                // hotspotLayer=new exri.layers.ArcGISTiledMapServiceLayer(mapurl, {  
                                //     "id": "bufferlayer"  
                                // });
                              map.addLayer(hotspotLayer);  
                              var s=map.layerIds;
                              console.log(s);
                            }, function(data){
                                console.log("status");
                                console.log(data);
                            }, function(data){
                                console.log("failed");
                                //console.log(data);
                        });
                    });
                }  
            }); 

 

GIS有关GP服务的发布和调用