管灌系统巡查员智能手机App
app/src/main/assets/js/map.js
@@ -27,6 +27,12 @@
    let pipeLineList = [];
    let currentPipePath = [];
    // 存储所有取水口标记的数组
    let waterIntakeMarkers = [];
    // 存储所有分水房标记的数组
    let divideMarkers = [];
    // 将方法挂载到 window 上
    function mountMethodToWindow() {
        window.locationOverLay = locationOverLay;
@@ -46,6 +52,10 @@
        window.hideAllPipeLines = hideAllPipeLines;
        window.clearAllPipeLines = clearAllPipeLines;
        window.addPipeNetwork = addPipeNetwork;
        window.hideAllWaterIntakes = hideAllWaterIntakes;
        window.showAllWaterIntakes = showAllWaterIntakes;
        window.hideAllDivides = hideAllDivides;
        window.showAllDivides = showAllDivides;
    }
@@ -242,19 +252,26 @@
        let label = new T.Label({
            text: `<div style='position:absolute;left:-50%;transform: translateX(-50%);'>${name}<div>`,
            position: marker.getLngLat(),
            offset: new T.Point(0, 8), // 设置标注文字的位置
            opacity: 1, // 设置文本的显示不透明度(范围0-1)
            offset: new T.Point(0, 8),
            opacity: 1,
        });
        label.setBorderLine(0); // 设置文本的边框线宽
        label.setBackgroundColor("transparent"); // 设置文本的背景色(透明色)
        label.setBorderLine(0);
        label.setBackgroundColor("transparent");
        label.setFontColor("#FFFFFF");
        label.setFontSize(10);
        marker.label = label;
        if (isRed) {
            lastClickedMarker = marker;
        }
        // 将标记和标签存储到数组中
        waterIntakeMarkers.push({
            marker: marker,
            label: label
        });
        map.addOverLay(label);
        map.addOverLay(marker); // 将标注添加到地图中
        map.addOverLay(marker);
        return "addMarker加载成功 id:" + id
    }
    //更新位坐标
@@ -538,6 +555,13 @@
        if (isRed) {
            lastClickedMarker = marker;
        }
        // 将分水房标记和标签存储到数组中
        divideMarkers.push({
            marker: marker,
            label: label
        });
        map.addOverLay(label);
        map.addOverLay(marker); // 将标注添加到地图中
        return "addMarker加载成功 id:" + id
@@ -577,9 +601,44 @@
        window.Android.showDivideDetail(data);
    }
    /**
     * 隐藏所有取水口标记
     */
    function hideAllWaterIntakes() {
        waterIntakeMarkers.forEach(item => {
            map.removeOverLay(item.marker);
            map.removeOverLay(item.label);
        });
    }
    /**
     * 显示所有取水口标记
     */
    function showAllWaterIntakes() {
        waterIntakeMarkers.forEach(item => {
            map.addOverLay(item.marker);
            map.addOverLay(item.label);
        });
    }
    /**
     * 隐藏所有分水房标记
     */
    function hideAllDivides() {
        divideMarkers.forEach(item => {
            map.removeOverLay(item.marker);
            map.removeOverLay(item.label);
        });
    }
    /**
     * 显示所有分水房标记
     */
    function showAllDivides() {
        divideMarkers.forEach(item => {
            map.addOverLay(item.marker);
            map.addOverLay(item.label);
        });
    }
})();