执行buffer
转:http://lishalongfa.blog.163.com/blog/static/38971473201251345912868/
function Buffer()
{
if(dojo.byId('bufferDistance').value === '0' || dojo.byId('bufferDistance').value === "")
alert("please input a valid distance for buffer!");
else
dojo.forEach(esri.getGeometries(selectResults), doBuffer);
}
function doBuffer(geometry) {
bufferGraphics.clear();
var bufferDistance = dojo.byId('bufferDistance').value;
var params = new esri.tasks.BufferParameters();
params.geometries = geometry;
params.distances = [ bufferDistance ];
params.bufferSpatialReference = new esri.SpatialReference({ 'wkid': 102100 });
params.outSpatialReference = map.spatialReference;
params.unit = esri.tasks.GeometryService.UNIT_STATUTE_MILE;
params.unionResults = true;
//This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications.
if (geometry.type === "polygon") {
//if geometry is a polygon then simplify polygon. This will make the user drawn polygon topologically correct.
geometryService.simplify([geometry], function(geometries) {
params.geometries = geometries;
geometryService.buffer(params, showBuffer);
});
} else {
params.geometries = [geometry];
geometryService.buffer(params, showBuffer);
}
}
function showBuffer(buffer) {
// Add the buffer graphic to the map
var polySym = new esri.symbol.SimpleFillSymbol()
.setColor(new dojo.Color([56, 102, 164, 0.4]))
.setOutline(
new esri.symbol.SimpleLineSymbol()
.setColor(new dojo.Color([56, 102, 164, 0.8]))
);
var bufferGraphic = new esri.Graphic(buffer[0], polySym);
bufferGraphics.add(bufferGraphic);
// Send buffer to runction to calculate population
//calcPop(bufferGraphic);
}
geometry Service:http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer
转载自:https://blog.csdn.net/wt346326775/article/details/52756519