Skip to content

YY. MeasureTool

测量工具类,用来测距,测面积

常量Description
YY. MeasureTool. DISTANCE开启测距
YY. MeasureTool. AREA开启测面积

creation

  • constructor(map, [options1], [options2])
    • map {YY. Map} 地图对象
    • options1 {Object} 测距工具样式的配置,一般情况下无需配置,如需配置参考
js
//请参考其值
console.log(YY.MeasureTool.DISTANCESTYLE);
const DistancleOptions = {
    symbol: {
        lineColor: "#3388FF",
        lineWidth: 2,
    },
    vertexSymbol: {
        markerType: "ellipse",
        markerFill: "#1bbc9b",
        markerLineColor: "#000",
        markerLineWidth: 3,
        markerWidth: 10,
        markerHeight: 10,
    },

    labelOptions: {
        textSymbol: {
            textFaceName: "monospace",
            textFill: "#fff",
            textLineSpacing: 1,
            textHorizontalAlignment: "right",
            textDx: 15,
            markerLineColor: "#b4b3b3",
            markerFill: "#000",
        },
        boxStyle: {
            padding: [6, 2],
            symbol: {
                markerType: "square",
                markerFill: "#000",
                markerFillOpacity: 0.9,
                markerLineColor: "#b4b3b3",
            },
        },
    },
    clearButtonSymbol: [{
            markerType: "square",
            markerFill: "#000",
            markerLineColor: "#b4b3b3",
            markerLineWidth: 2,
            markerWidth: 15,
            markerHeight: 15,
            markerDx: 20,
        },
        {
            markerType: "x",
            markerWidth: 10,
            markerHeight: 10,
            markerLineColor: "#fff",
            markerDx: 20,
        },
    ],
    language: "en-US",
};
  • options2 {Object} 侧面积样式的配置,一般情况下无需配置, 如需配置参考
js
//请参考其值
console.log(YY.MeasureTool.AREASTYLE);

const AreaOptions = {
    symbol: {
        lineColor: "#3388FF",
        lineWidth: 2,
        polygonFill: "#3388FF",
        polygonOpacity: 0.3,
    },
    vertexSymbol: {
        markerType: "ellipse",
        markerFill: "#34495e",
        markerLineColor: "#1bbc9b",
        markerLineWidth: 3,
        markerWidth: 10,
        markerHeight: 10,
    },
    labelOptions: {
        textSymbol: {
            textFaceName: "monospace",
            textFill: "#fff",
            textLineSpacing: 1,
            textHorizontalAlignment: "right",
            textDx: 15,
        },
        boxStyle: {
            padding: [6, 2],
            symbol: {
                markerType: "square",
                markerFill: "#000",
                markerFillOpacity: 0.9,
                markerLineColor: "#b4b3b3",
            },
        },
    },
    clearButtonSymbol: [{
            markerType: "square",
            markerFill: "#000",
            markerLineColor: "#b4b3b3",
            markerLineWidth: 2,
            markerWidth: 15,
            markerHeight: 15,
            markerDx: 22,
        },
        {
            markerType: "x",
            markerWidth: 10,
            markerHeight: 10,
            markerLineColor: "#fff",
            markerDx: 22,
        },
    ],
    language: "",
};

example

demo

js
var measureTool = new YY.MeasureTool(map);
measureTool.activate(YY.MeasureTool.DISTANCE); //开启测距
measureTool.activate(YY.MeasureTool.AREA); //开启测面积

method

activate(type)

  • 激活测量工具
  • 参数
    • {String} type: 'Distance'||'Area' 或者利用静态常量 YY.MeasureTool.DISTANCE ||YY.MeasureTool.AREA
  • 返回值: this

deactivate()

  • 关闭测量工具
  • 返回值: this

clear()

  • 清除测量数据
  • 返回值: this

This document is generated by vitepress and Edit by deyihu