Skip to content

量测插件

量测插件的引用

HTML
<!--1).引用插件css文件 -->
<link href="Plugins/Measure/Measure.css" rel="stylesheet" type="text/css"/>
<!-- 如果想改变插件的位置修改该css文件即可 -->

<!--2).引用插件javascript文件 -->
<script type="text/javascript" src="Plugins/Measure/Measure.js"></script>

初始化量测插件

点位测量

JavaScript
    // 点位测量
    function drawPoint() {
        if (!LSGlobe.defined(viewer)) return;
        //开始点位测量,鼠标点击,鼠标click事件后自动结束
        viewer.measureEditer.viewModel.Point();
    }
    function clearPoint() {
        if (!LSGlobe.defined(viewer)) return;
        //清除点位测量结果
        viewer.measureEditer.viewModel.PointClear();
    }

空间距离测量

JavaScript
    // 空间距离测量
    function drawDistance() {
        if (!LSGlobe.defined(viewer)) return;
        //开始距离测量,鼠标双击后自动结束
        viewer.measureEditer.viewModel.measureType = LSGlobe.LSMeasureType.SPACE
        viewer.measureEditer.viewModel.Distance();
    }
    function clearDistance() {
        if (!LSGlobe.defined(viewer)) return;
        //清除距离测量结果
        viewer.measureEditer.viewModel.DistanceClear();
    }

投影距离测量

JavaScript
    // 投影距离测量
    function drawSphereDistance() {
        if (!LSGlobe.defined(viewer)) return;
        //开始距离测量,鼠标双击后自动结束
        viewer.measureEditer.viewModel.measureType = LSGlobe.LSMeasureType.SPHERE
        viewer.measureEditer.viewModel.Distance();
    }
    function clearSphereDistance() {
        if (!LSGlobe.defined(viewer)) return;
        //清除距离测量结果
        viewer.measureEditer.viewModel.DistanceClear();
    }

地表距离测量

JavaScript
    // 地表距离测量
    function drawGroundDistance() {
        if (!LSGlobe.defined(viewer)) return;
        //开始距离测量,鼠标双击后自动结束
        viewer.measureEditer.viewModel.measureType = LSGlobe.LSMeasureType.GROUND
        viewer.measureEditer.viewModel.Distance();
    }
    function clearGroundDistance() {
        if (!LSGlobe.defined(viewer)) return;
        //清除距离测量结果
        viewer.measureEditer.viewModel.DistanceClear();
    }

空间面测量

JavaScript
    // 空间面测量
    function drawMeasure() {
        if (!LSGlobe.defined(viewer)) return;
        //开始面积测量,鼠标双击后自动结束
        viewer.measureEditer.viewModel.measureType = LSGlobe.LSMeasureType.SPACE
        viewer.measureEditer.viewModel.AreaMeasure();
    }
    function clearMeasure() {
        if (!LSGlobe.defined(viewer)) return;
        //清除面积测量结果
        viewer.measureEditer.viewModel.AreaMeasureClear();
    }

空间面测量

JavaScript
    // 空间面测量
    function drawMeasure() {
        if (!LSGlobe.defined(viewer)) return;
        //开始面积测量,鼠标双击后自动结束
        viewer.measureEditer.viewModel.measureType = LSGlobe.LSMeasureType.SPACE
        viewer.measureEditer.viewModel.AreaMeasure();
    }
    function clearMeasure() {
        if (!LSGlobe.defined(viewer)) return;
        //清除面积测量结果
        viewer.measureEditer.viewModel.AreaMeasureClear();
    }

投影面测量

JavaScript
    // 投影面测量
    function drawSphereMeasure() {
        if (!LSGlobe.defined(viewer)) return;
        //开始面积测量,鼠标双击后自动结束
        viewer.measureEditer.viewModel.measureType = LSGlobe.LSMeasureType.SPHERE
        viewer.measureEditer.viewModel.AreaMeasure();
    }
    function clearSphereMeasure() {
        if (!LSGlobe.defined(viewer)) return;
        //清除面积测量结果
        viewer.measureEditer.viewModel.AreaMeasureClear();
    }

地表面测量

JavaScript
    // 地表面测量
    function drawGroundMeasure() {
        if (!LSGlobe.defined(viewer)) return;
        //开始面积测量,鼠标双击后自动结束
        viewer.measureEditer.viewModel.measureType = LSGlobe.LSMeasureType.GROUND
        viewer.measureEditer.viewModel.AreaMeasure();
    }
    function clearGroundMeasure() {
        if (!LSGlobe.defined(viewer)) return;
        //清除面积测量结果
        viewer.measureEditer.viewModel.AreaMeasureClear();
    }

高度测量

JavaScript
    // 高度测量
    function drawHeight() {
        if (!LSGlobe.defined(viewer)) return;
        //开始三角测量,鼠标双击后自动结束
        viewer.measureEditer.viewModel.HeightMeasure();
    }
    function clearHeight() {
        if (!LSGlobe.defined(viewer)) return;
        //清除三角测量结果
        viewer.measureEditer.viewModel.HeightMeasureClear();
    }

清除所有测量结果

JavaScript
    function clearAll() {
        if (!LSGlobe.defined(viewer)) return;
        //清除所有测量结果
        viewer.measureEditer.viewModel.ClearAll();
    }

示例代码 code

code示例地址

Released under the MIT License.