代码如下:
function drawPolygonGeometry() {
//先清除上次的显示结果
clearElements();
drawPolygon.activate();
}
function drawCompleted(drawGeometryArgs) {
drawPolygon.deactivate();
feature = new SuperMap.Feature.Vector();
feature.geometry = drawGeometryArgs.feature.geometry,
feature.style = style;
vectorLayer.addFeatures(feature);
}
function bufferAnalystProcess() {
if (!feature.geometry) {
alert("请确定缓冲中心点");
return;
}
var bufferServiceByGeometry = new SuperMap.REST.BufferAnalystService(url2),
bufferDistance = new SuperMap.REST.BufferDistance({
value: prompt("选择缓冲距离")
}),
bufferSetting = new SuperMap.REST.BufferSetting({
endType: SuperMap.REST.BufferEndType.ROUND,
leftDistance: bufferDistance,
rightDistance: bufferDistance,
semicircleLineSegment: 100
}),
geoBufferAnalystParam = new SuperMap.REST.GeometryBufferAnalystParameters({
sourceGeometry: feature.geometry,
bufferSetting: bufferSetting
});
bufferServiceByGeometry.events.on(
{
"processCompleted": bufferAnalystCompleted
});
bufferServiceByGeometry.processAsync(geoBufferAnalystParam);
}
function bufferAnalystCompleted(BufferAnalystEventArgs) {
var feature = new SuperMap.Feature.Vector();
bufferResultGeometry = BufferAnalystEventArgs.result.resultGeometry;
feature.geometry = bufferResultGeometry;
feature.style = styleRegion;
resultLayer.addFeatures(feature);
}