打印服务范例:http://blog.csdn.net/jingxinwjb/article/details/51906464
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、范例:同步用execute 异步用submitJob方法
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);
});
});
}
});