请问你使用的是哪个框架呢,是否方便发一下关键性代码。测量面积的接口可以使用封装好的接口,可以参考https://iclient.supermap.io/examples/openlayers/editor.html#01_measure_area
用的WebGL的量算,http://support.supermap.com.cn:8090/webgl/examples/webgl/editor.html#measureHandler
下面的measureEvt.addEventListene里面的positions
//初始化测量面积 handlerArea = new Cesium.MeasureHandler(viewer, Cesium.MeasureMode.Area, clampMode); handlerArea.measureEvt.addEventListener(function (result) { var mj = Number(result.area); var selOptV = $("#selOpt").val(); var positions = result.positions; if (selOptV == 3 || selOptV == 4) { mj = Number(calcClampValue(positions)); } else if (selOptV == 5) { mj = Number(calcAreaWithoutHeight(positions)); }
var area = mj > 1000000 ? (mj / 1000000).toFixed(2) + 'km²' : mj.toFixed(2) + '㎡' handlerArea.areaLabel.text = '面积:' + area; }); handlerArea.activeEvt.addEventListener(function (isActive) { if (isActive == true) { viewer.enableCursorStyle = false; viewer._element.style.cursor = ''; $('body').removeClass('measureCur').addClass('measureCur'); } else { viewer.enableCursorStyle = true; $('body').removeClass('measureCur'); } });