CJS代码参考如下:
require([ "esri/map", "esri/layers/ArcGISTiledMapServiceLayer", "esri/layers/ArcGISDynamicMapServiceLayer", "esri/geometry/Point", "esri/SpatialReference", "esri/layers/ImageParameters", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/TextSymbol", "esri/layers/LabelClass", "esri/renderers/SimpleRenderer", "esri/layers/FeatureLayer", "esri/Color", "esri/symbols/SimpleLineSymbol", "esri/layers/GraphicsLayer", "esri/graphic", "esri/tasks/FeatureSet", "esri/geometry/geometryEngine", "esri/tasks/Geoprocessor", "dojo/domReady!"], function(Map, ArcGISTiledMapServiceLayer,ArcGISDynamicMapServiceLayer, Point, SpatialReference, ImageParameters,SimpleMarkerSymbol,TextSymbol, LabelClass,SimpleRenderer,FeatureLayer,Color,SimpleLineSymbol,GraphicsLayer,Graphic,FeatureSet,geometryEngine,Geoprocessor) { var map = new Map("map", { // center: new Point(1.3091608700115489E7, 4273624.108445918, new SpatialReference({ wkid: 3857 })), autoResize:true, sliderStyle: "small", logo: false, showLabels : true }); var baseSpatialRef = new SpatialReference({"wkt":'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["degree",0.0174532925199433]]'}); var tiled = new ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services/sishui/sishuifeature/MapServer"); map.addLayer(tiled); var gp = new Geoprocessor("http://localhost:6080/arcgis/rest/services/test/dengzhimian/GPServer/dengzhimian"); //var gp = new Geoprocessor("http://localhost:6080/arcgis/rest/services/test/dengzhimian2/GPServer/dengzhimian2"); var graphicLayer = new GraphicsLayer({id:"dian"}); var sssym = new SimpleMarkerSymbol({ "color": [255,255,255,64], "size": 12, "angle": -30, "xoffset": 0, "yoffset": 0, "type": "esriSMS", "style": "esriSMSCircle", "outline": { "color": [0,0,0,255], "width": 1, "type": "esriSLS", "style": "esriSLSSolid" } }); var features = []; var graphic1 = new Graphic(new Point(117.320358,35.725506,baseSpatialRef),sssym,{"zvalue":10}); var graphic2 = new Graphic(new Point(117.251434,35.699341,baseSpatialRef),sssym,{"zvalue":30}); var graphic3 = new Graphic(new Point(117.522662,35.618930,baseSpatialRef),sssym,{"zvalue":400}); var graphic4 = new Graphic(new Point(117.275685,35.564684,baseSpatialRef),sssym,{"zvalue":28}); var graphic5 = new Graphic(new Point(117.447444,35.755972,baseSpatialRef),sssym,{"zvalue":70}); var graphic6 = new Graphic(new Point(117.155146,35.627075,baseSpatialRef),sssym,{"zvalue":100}); var graphic7 = new Graphic(new Point(117.404478,35.651812,baseSpatialRef),sssym,{"zvalue":0}); var graphic8 = new Graphic(new Point(117.105020,35.770945,baseSpatialRef),sssym,{"zvalue":180}); //显示数据源,用于展示等值面效果 graphicLayer.add(graphic1); graphicLayer.add(graphic2); graphicLayer.add(graphic3); graphicLayer.add(graphic4); graphicLayer.add(graphic5); graphicLayer.add(graphic6); graphicLayer.add(graphic7); graphicLayer.add(graphic8); map.addLayer(graphicLayer); //组装输入参数 features.push(graphic1); features.push(graphic2); features.push(graphic3); features.push(graphic4); features.push(graphic5); features.push(graphic6); features.push(graphic7); features.push(graphic8); var featureset = new FeatureSet(); featureset.features = features; var para = { inputpoints:featureset, zvalue:"zvalue" // clipfeature:"xian1" } //生成矢量等值面 gp.submitJob(para,function(result){ var mianGraphicLayer = new GraphicsLayer({id:"dengzhimian"}); var symbol = new esri.symbol.SimpleFillSymbol(); symbol.setColor(new dojo.Color([150,150,150,0.5])); var renderer = new esri.renderer.ClassBreaksRenderer(symbol, "gridcode");//根据输出矢量的gridcode字段分类渲染 renderer.addBreak(1,9,new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([56, 168, 0,0.5]))); renderer.addBreak(10,24,new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([139, 209, 0,0.5]))); renderer.addBreak(25,49,new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,255,0,0.5]))); renderer.addBreak(50,99,new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,128,0,0.5]))); renderer.addBreak(100,199,new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,128,0,0.5]))); renderer.addBreak(200,Infinity,new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255,0,0,0.5]))); mianGraphicLayer.setRenderer(renderer); var jobId = result.jobId; var status = result.jobStatus; if(status == esri.tasks.JobInfo.STATUS_SUCCEEDED) { //成功之后,将其中的结果取出来,当然这也是参数名字。 //在模型中,想要取出中间结果,需要设置为模型参数 gp.getResultData(jobId, "output", function(jobInfo){ var features = jobInfo.value.features; dojo.forEach(features,function(graphic){ mianGraphicLayer.add(graphic); }); map.addLayer(mianGraphicLayer); }); } }); });
原创文章,作者:506227337,如若转载,请注明出处:https://blog.ytso.com/272537.html