| | |
| | | |
| | | }); |
| | | window.onload = function () { |
| | | console.log(window.onload); // 打印数组数据 |
| | | //加载坐标点 |
| | | window.Android.loadMarker(); |
| | | }; |
| | |
| | | // 地图点击后获取经纬度 |
| | | function getLngLat(lnglat) { |
| | | console.log(lnglat.lng.toFixed(6) + "," + lnglat.lat.toFixed(6)); |
| | | addClickOverLay(lnglat); |
| | | // addClickOverLay(lnglat); |
| | | } |
| | | |
| | | // 点击后添加坐标点 |
| | |
| | | window.addMarker = addMarker; |
| | | window.setCenterAndZoom = setCenterAndZoom; |
| | | window.updateLocation = updateLocation; |
| | | window.aginShowLocation = aginShowLocation; |
| | | window.cleanLocationLay = cleanLocationLay; |
| | | window.updateInspectionLocation=updateInspectionLocation; |
| | | window.cleanLoclLay=cleanLoclLay; |
| | | |
| | | } |
| | | |
| | | // 调用原生安卓方法显示取水口详情 |
| | |
| | | }); |
| | | return "addMarker加载成功" |
| | | } |
| | | //更新定位坐标 |
| | | function updateLocation(log, lat) { |
| | | let icon = new T.Icon({ |
| | | iconUrl: locationIMGPath, |
| | | iconSize: new T.Point(20, 20), |
| | | iconAnchor: new T.Point(10, 10) |
| | | }); |
| | | if (locationMarker) { |
| | | map.removeOverLay(locationMarker); |
| | | } |
| | | var newPoint = new T.LngLat(log, lat); |
| | | locationMarker = new T.Marker(newPoint, { icon: icon }); |
| | | map.addOverLay(locationMarker); |
| | | map.panTo(newPoint); |
| | | } |
| | | //保存定位坐标生成轨迹 |
| | | var path = []; |
| | | var lineLayer = new T.Polyline([], { color: '#ff4500', weight: 3, opacity: 0.8 }); |
| | | let locationMarker; |
| | | function updateLocation(log, lat) { |
| | | function updateInspectionLocation(log, lat) { |
| | | var lastLat = lat; |
| | | // const intervalId = setInterval(() => { |
| | | // lastLat=lastLat+0.0001; |
| | |
| | | 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) |
| | | }); |
| | | // 移动地图视角到最后一个位置 |
| | | |
| | | // }, 500); |
| | | } |
| | | |
| | | var aginPath = []; |
| | | var oldLineLayer = new T.Polyline([], { color: '#ff4500', weight: 3, opacity: 0.8 }); |
| | | //显示因异常关闭的巡检记录 |
| | | function aginShowLocation(lng, lat) { |
| | | // 调用 Android 提供的接口,获取数据 |
| | | console.log("aginShowLocation>>lng:" + lng + ">>>lat:" + lat); |
| | | var newPoint = new T.LngLat(lng, lat); |
| | | aginPath.push(newPoint); |
| | | oldLineLayer.setLngLats(aginPath); |
| | | map.addOverLay(oldLineLayer); |
| | | } |
| | | //清除巡检记录轨迹 |
| | | function cleanLocationLay() { |
| | | if (lineLayer) { |
| | | map.removeOverLay(lineLayer); |
| | | path=[] |
| | | } |
| | | if (locationMarker) { |
| | | map.removeOverLay(locationMarker); |
| | | } |
| | | locationMarker = new T.Marker(new T.LngLat(log, lastLat), { icon: icon }); |
| | | map.addOverLay(locationMarker); |
| | | // 移动地图视角到最后一个位置 |
| | | map.panTo(newPoint); |
| | | // }, 500); |
| | | |
| | | if (oldLineLayer) { |
| | | aginPath=[] |
| | | map.removeOverLay(oldLineLayer); |
| | | } |
| | | } |
| | | //清除本地定位坐标位置 |
| | | function cleanLoclLay(){ |
| | | if (locationMarker) { |
| | | map.removeOverLay(locationMarker); |
| | | } |
| | | } |
| | | |
| | | |