| | |
| | | |
| | | // 手机获取到定位后显示定位 |
| | | function locationOverLay(lng, lag) { |
| | | console.log("function》》》》》locationOverLay"); |
| | | // console.log("function》》》》》locationOverLay"); |
| | | map.centerAndZoom(new T.LngLat(lng, lag), map.getZoom()); |
| | | let icon = new T.Icon({ |
| | | iconUrl: CONFIG.IMAGES.LOCATION, |
| | |
| | | //设置地图中心点 |
| | | function setCenterAndZoom(lng, lat, thiszoom) { |
| | | zoom = thiszoom; |
| | | console.log("function》》》》》setCenterAndZoom>>>>lng:" + lng + ",lat:" + lat); |
| | | // console.log("function》》》》》setCenterAndZoom>>>>lng:" + lng + ",lat:" + lat); |
| | | map.centerAndZoom(new T.LngLat(lng, lat), zoom); |
| | | } |
| | | |
| | |
| | | if (lastClickedMarker !== null) { |
| | | lastClickedMarker.setIcon(createIcon(CONFIG.IMAGES.MARKER_BLUE)); |
| | | } |
| | | if(lastClickedDivide!==null) |
| | | { |
| | | lastClickedDivide.setIcon(createIcon(CONFIG.IMAGES.DIVIDE_BLUE)); |
| | | } |
| | | if (lastClickedDivide !== null) { |
| | | lastClickedDivide.setIcon(createIcon(CONFIG.IMAGES.DIVIDE_BLUE)); |
| | | } |
| | | if (isShowWaterIntakeDetail || isShowDivideDetail) { |
| | | // 假如显示了取水口详情则隐藏取水口详情 |
| | | isShowWaterIntakeDetail = false; |
| | |
| | | function isEqualsLngLat(data1, data2) { |
| | | return data1.lat === data2.lat && data1.lng === data2.lng; |
| | | } |
| | | function addMarker(id, lng, lat, name) { |
| | | addMarker(id, lng, lat, name, false) |
| | | function addMarker(id, lng, lat, name, isShow) { |
| | | addMyMarker(id, lng, lat, name, false, isShow) |
| | | } |
| | | //添加从原生传过来的坐标并显示在地图上 |
| | | function addMarker(id, lng, lat, name, isRed) { |
| | | console.log("function》》》》》addMarker>>>id:" + id); |
| | | |
| | | function addMyMarker(id, lng, lat, name, isRed, isShow) { |
| | | const iconUrl = isRed ? CONFIG.IMAGES.MARKER_RED : CONFIG.IMAGES.MARKER_BLUE; |
| | | let marker = new T.Marker( |
| | | new T.LngLat(lng, lat), |
| | |
| | | if (isRed) { |
| | | lastClickedMarker = marker; |
| | | } |
| | | |
| | | |
| | | // 将标记和标签存储到数组中 |
| | | waterIntakeMarkers.push({ |
| | | marker: marker, |
| | | label: label |
| | | }); |
| | | |
| | | map.addOverLay(label); |
| | | map.addOverLay(marker); |
| | | if (isShow === "true" || isShow === true) { |
| | | map.addOverLay(label); |
| | | map.addOverLay(marker); |
| | | } |
| | | return "addMarker加载成功 id:" + id |
| | | } |
| | | //更新位坐标 |
| | |
| | | |
| | | // 管网线路管理 |
| | | const PipelineManager = { |
| | | lines: [], // 存储所有完成的线路 |
| | | lines: [], |
| | | currentLine: { |
| | | points: [], // 当前线路的点 |
| | | overlay: null // 当前线路的图层对象 |
| | | points: [], |
| | | overlay: null |
| | | }, |
| | | |
| | | // 线路样式配置 |
| | | |
| | | style: { |
| | | color: '#1890FF', |
| | | weight: 3, |
| | | opacity: 0.8 |
| | | }, |
| | | |
| | | /** |
| | | * 添加点到管网线路 |
| | | * @param {number} lng 经度 |
| | | * @param {number} lat 纬度 |
| | | * @param {boolean} isNewLine 是否开始新的线路 |
| | | */ |
| | | addPoint(lng, lat, isNewLine) { |
| | | if (isNewLine) { |
| | | this.finishCurrentLine(); |
| | | } |
| | | |
| | | |
| | | addPoint(lng, lat, isNewLine, isShow) { |
| | | // console.log(`Adding point: ${lng}, ${lat}, isNewLine: ${isNewLine}`); // 添加日志 |
| | | |
| | | const point = new T.LngLat(lng, lat); |
| | | this.currentLine.points.push(point); |
| | | |
| | | if (this.currentLine.points.length > 1) { |
| | | this.updateCurrentLineDisplay(); |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 更新当前线路的显示 |
| | | */ |
| | | updateCurrentLineDisplay() { |
| | | if (!this.currentLine.overlay) { |
| | | // 创建新的线路图层 |
| | | this.currentLine.overlay = new T.Polyline(this.currentLine.points, this.style); |
| | | map.addOverLay(this.currentLine.overlay); |
| | | } else { |
| | | // 更新现有线路的点 |
| | | this.currentLine.overlay.setLngLats(this.currentLine.points); |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 完成当前线路 |
| | | */ |
| | | finishCurrentLine() { |
| | | if (this.currentLine.points.length > 1) { |
| | | if (this.currentLine.overlay) { |
| | | // 将当前线路添加到完成列表 |
| | | this.lines.push(this.currentLine.overlay); |
| | | |
| | | // 修改判断逻辑,确保字符串"false"被正确处理 |
| | | const shouldCreateNewLine = isNewLine === true || isNewLine === "true" || !this.currentLine.overlay; |
| | | |
| | | if (shouldCreateNewLine) { |
| | | // 创建新线路 |
| | | this.currentLine.points = [point]; |
| | | this.currentLine.overlay = new T.Polyline([point], this.style); |
| | | if (isShow === true || isShow === "true") { |
| | | map.addOverLay(this.currentLine.overlay); |
| | | } |
| | | } else if (this.currentLine.overlay) { |
| | | // 如果点数不足,清除图层 |
| | | map.removeOverLay(this.currentLine.overlay); |
| | | } else { |
| | | // 添加点到现有线路 |
| | | this.currentLine.points.push(point); |
| | | this.currentLine.overlay.setLngLats(this.currentLine.points); |
| | | |
| | | } |
| | | |
| | | // 重置当前线路 |
| | | this.currentLine = { |
| | | points: [], |
| | | overlay: null |
| | | }; |
| | | // 如果是新线路,将之前的线路保存到 lines 数组 |
| | | if (isNewLine === true || isNewLine === "true") { |
| | | this.lines.push({ |
| | | points: [...this.currentLine.points], |
| | | overlay: this.currentLine.overlay |
| | | }); |
| | | } |
| | | }, |
| | | |
| | | /** |
| | | * 显示所有线路 |
| | | */ |
| | | |
| | | showAll() { |
| | | this.lines.forEach(line => map.addOverLay(line)); |
| | | if (this.currentLine.overlay) { |
| | | map.addOverLay(this.currentLine.overlay); |
| | | } |
| | | // console.log("showAllpipe" + this.lines.length); |
| | | this.lines.forEach(line => { |
| | | if (line.overlay) { |
| | | map.addOverLay(line.overlay); |
| | | } |
| | | }); |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 隐藏所有线路 |
| | | */ |
| | | |
| | | hideAll() { |
| | | this.lines.forEach(line => map.removeOverLay(line)); |
| | | if (this.currentLine.overlay) { |
| | | map.removeOverLay(this.currentLine.overlay); |
| | | } |
| | | // console.log("hideAllpipe" + this.lines.length); |
| | | this.lines.forEach(line => { |
| | | if (line.overlay) { |
| | | map.removeOverLay(line.overlay); |
| | | } |
| | | }); |
| | | }, |
| | | |
| | | /** |
| | | * 清除所有线路 |
| | | */ |
| | | |
| | | clearAll() { |
| | | this.hideAll(); |
| | | this.lines = []; |
| | |
| | | /** |
| | | * 添加管网线路点 |
| | | */ |
| | | function addPipeNetwork(lng, lat, isNewLine) { |
| | | PipelineManager.addPoint(lng, lat, isNewLine); |
| | | function addPipeNetwork(lng, lat, isNewLine, isShow) { |
| | | PipelineManager.addPoint(lng, lat, isNewLine, isShow); |
| | | } |
| | | |
| | | /** |
| | |
| | | function refreshMarker(id, lng, lat, name) { |
| | | map.removeOverLay(lastClickedMarker.label); |
| | | map.removeOverLay(lastClickedMarker); |
| | | addMarker(id, lng, lat, name, true); |
| | | addMarker(id, lng, lat, name, true, true); |
| | | } |
| | | |
| | | |
| | | function mapMoveEnd(e) { |
| | | |
| | | const center = e.target.getCenter(); |
| | | window.Android.refreshCenter(center.getLng(), center.getLat()); |
| | | const center = e.target.getCenter(); |
| | | window.Android.refreshCenter(center.getLng(), center.getLat()); |
| | | |
| | | } |
| | | |
| | |
| | | }); |
| | | } |
| | | //添加分水房 |
| | | function addDivide(id, lng, lat, name) { |
| | | addDivide(id, lng, lat, name, false) |
| | | function addDivide(id, lng, lat, name, isShow) { |
| | | addMyDivide(id, lng, lat, name, false, isShow) |
| | | } |
| | | //添加分水房 |
| | | function addDivide(id, lng, lat, name, isRed) { |
| | | function addMyDivide(id, lng, lat, name, isRed, isShow) { |
| | | console.log("function》》》》》addMarker>>>id:" + id); |
| | | |
| | | const iconUrl = isRed ? CONFIG.IMAGES.DIVIDE_RED : CONFIG.IMAGES.DIVIDE_BLUE; |
| | |
| | | marker: marker, |
| | | label: label |
| | | }); |
| | | |
| | | map.addOverLay(label); |
| | | map.addOverLay(marker); // 将标注添加到地图中 |
| | | if (isShow === true || isShow === "true") { |
| | | map.addOverLay(label); |
| | | map.addOverLay(marker); // 将标注添加到地图中 |
| | | } |
| | | return "addMarker加载成功 id:" + id |
| | | } |
| | | // 修改点击标注的图标 |