1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| require(["esri/map", "esri/geometry/Point", "esri/graphic", "esri/symbols/SimpleMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "esri/tasks/Geoprocessor", "esri/tasks/FeatureSet", "esri/tasks/LinearUnit", "dojo/domReady!"], function (Map, Point, Graphic, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, Geoprocessor, FeatureSet, LinearUnit) { map = new Map("map", { basemap: "osm", zoom: 5 }); map.on("click", function (evt) { var symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CROSS, 12, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 2), new dojo.Color([0, 255, 0, 0.25])); var graphic = new Graphic(evt.mapPoint, symbol); map.graphics.add(graphic); var gp = new Geoprocessor("http://localhost:6080/arcgis/rest/services/webgis/BufferGP/GPServer/BufferModel");
var featureSet = new FeatureSet(); featureSet.fields = []; featureSet.features = [graphic];
var dis = new LinearUnit({ "distance": 10000, "units": "esriMeters" });
var bufferParams = { input: featureSet, dis: dis }; gp.execute(bufferParams, showResult, function (err) { console.log(err) }) }) function showResult(results) { console.log(results) var features = results[0].value.features; for (var i = 0; i < features.length; i++) { var geo = features[i].geometry; var line = new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255, 0, 0]), 1); var fill = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, line, new dojo.Color([255, 255, 0, 0.25])); map.graphics.add(new Graphic(geo, fill)); } } });
|