管灌系统巡查员智能手机App
app/src/main/assets/js/map.js
@@ -30,12 +30,12 @@
            "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=d8beed89b43160a9a185e5aff431f85d";
        //创建自定义图层对象
        //影像注记(地图上的地址)
        var imgURL2 ="http://t0.tianditu.gov.cn/cia_w/wmts?" +"SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
        "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}" +
        "&tk=d8beed89b43160a9a185e5aff431f85d";
        var imgURL2 = "http://t0.tianditu.gov.cn/cia_w/wmts?" + "SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cia&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles" +
            "&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}" +
            "&tk=d8beed89b43160a9a185e5aff431f85d";
        var lay = new T.TileLayer(imageURL, { minZoom: 6, maxZoom: 18 });
        var lay2 = new T.TileLayer(imgURL2, { minZoom: 6, maxZoom: 18 });
        var config = { layers: [lay,lay2] };
        var config = { layers: [lay, lay2] };
        map = new T.Map("mapDiv", config);
        var scale = new T.Control.Scale();
        //添加比例尺控件
@@ -153,8 +153,8 @@
    //设置地图中心点
    function setCenterAndZoom(lng, lat,thiszoom) {
    zoom=thiszoom;
    function setCenterAndZoom(lng, lat, thiszoom) {
        zoom = thiszoom;
        console.log("function》》》》》setCenterAndZoom>>>>lng:" + lng + ",lat:" + lat);
        map.centerAndZoom(new T.LngLat(lng, lat), zoom);
    }
@@ -166,7 +166,7 @@
        window.showToast = showToast;
        window.addMarker = addMarker;
        window.setCenterAndZoom = setCenterAndZoom;
        window.updateLocation=updateLocation;
        window.updateLocation = updateLocation;
    }
    // 调用原生安卓方法显示取水口详情
@@ -260,7 +260,7 @@
                position: marker.getLngLat(),
                offset: new T.Point(-35, 8), // 设置标注文字的位置
                opacity: 1, // 设置文本的显示不透明度(范围0-1)
                    });
            });
            label.setBorderLine(0); // 设置文本的边框线宽
            label.setBackgroundColor("transparent"); // 设置文本的背景色(透明色)
            label.setFontColor("#0000FF");
@@ -270,23 +270,32 @@
        return "addMarker加载成功"
    }
    //保存定位坐标生成轨迹
    var path=[];
    var lineLayer = new T.Polyline([], { color: 'red', weight: 3, opacity: 0.8 });
    function updateLocation(log,lat){
        var lastLat=lat;
    var path = [];
    var lineLayer = new T.Polyline([], { color: '#ff4500', weight: 3, opacity: 0.8 });
    let locationMarker;
    function updateLocation(log, lat) {
        var lastLat = lat;
        // const intervalId = setInterval(() => {
            // lastLat=lastLat+0.0001;
            var newPoint = new T.LngLat(log,lastLat);
            path.push(newPoint);
            lineLayer.setLngLats(path);
            map.addOverLay(lineLayer);
             // 移动地图视角到最后一个位置
             map.panTo(newPoint);
        // lastLat=lastLat+0.0001;
        var newPoint = new T.LngLat(log, lastLat);
        path.push(newPoint);
        lineLayer.setLngLats(path);
        map.addOverLay(lineLayer);
        let icon = new T.Icon({
            iconUrl: locationIMGPath,
            iconSize: new T.Point(27, 27),
            iconAnchor: new T.Point(13, 20)
        });
        if (locationMarker) {
            map.removeOverLay(locationMarker);
        }
        locationMarker = new T.Marker(new T.LngLat(log, lastLat), { icon: icon });
        map.addOverLay(locationMarker);
        // 移动地图视角到最后一个位置
        map.panTo(newPoint);
        // }, 500);
    }
})();