新手求教,代码如下
// 加载图层
function addLayer() {
// 向Map添加图层
map.addLayers([layer,lineLayer]);
map.setCenter(new SuperMap.LonLat(0,0),0);
}
// 绘制线段结束后触发函数,获取绘制的线段,并执行量算
function drawCompleted(arguments){
//屏蔽绘制线段控件
drawLine.deactivate();
// 获取绘制的线段
var geometry = arguments.feature.geometry,
measureParam = new SuperMap.REST.MeasureParameters(geometry);
// 定义量算服务对象,执行量算
var measureService = new SuperMap.REST.MeasureService(url, {
measureMode: SuperMap.REST.MeasureMode.DISTANCE,
eventListeners:{'processCompleted': measureCompleted,'processFailed':processFailed}
});
measureService.processAsync(measureParam);
}
//距离量算
function distanceMeasure(){
//清空上一次绘制的线段
lineLayer.removeAllFeatures();
// 激活绘制线段控件
drawLine.activate();
}
// 获取量算结果
function measureCompleted(measureEventArgs){
// 获取量算结果和计量单位
var distance = measureEventArgs.result.distance,
unit = measureEventArgs.result.unit;
if (distance != -1) {
alert(distance +unit);
}
}
//量算失败触发函数
function processFailed(MeasureEventArgs){
alert("ok");
}
// 绘制线段结束后触发函数,获取绘制的线段,并执行量算
function drawCompleted(arguments){
//屏蔽绘制线段控件
drawPolygon.deactivate();
// 获取绘制的线段
var geometry = arguments.feature.geometry,
measureParam = new SuperMap.REST.MeasureParameters(geometry);
// 定义量算服务对象,执行量算
var measureService = new SuperMap.REST.MeasureService(url, {
measureMode: SuperMap.REST.MeasureMode.AREA,
eventListeners:{'processCompleted': measureCompleted,'processFailed':processFailed}
});
measureService.processAsync(measureParam);
}
//面积量算
function areaMeasure(){
//清空上一次绘制的面
lineLayer.removeAllFeatures();
// 激活绘制面控件
drawPolygon.activate();
}
// 获取量算结果
function measureCompleted(measureEventArgs){
// 获取量算结果和计量单位
var area = measureEventArgs.result.area,
unit = measureEventArgs.result.unit;
if (area != -1) {
alert(area +unit);
}
}
//量算失败触发函数
function processFailed(MeasureEventArgs){
alert("ok");
}
结果距离量算测出的是面积值
能具体说明一下怎样修改吗