From f9304384263a22b26d18fc1ff967b442971382b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=B0=8F?= <736883394@qq.com> Date: Tue, 13 May 2025 09:22:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=99=E7=82=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/devops/bikesite/bikesite-info.vue | 187 ++++++++------ .../pages/devops/bikesite/bikesite-list.vue | 231 +++++++++--------- ebike-maintenance/pages/map/map-bikesite.css | 11 +- ebike-maintenance/pages/map/map-bikesite.vue | 87 ++++--- ebike-maintenance/utils/map.js | 76 +----- 5 files changed, 298 insertions(+), 294 deletions(-) diff --git a/ebike-maintenance/pages/devops/bikesite/bikesite-info.vue b/ebike-maintenance/pages/devops/bikesite/bikesite-info.vue index 3eb75e9..733b5ae 100644 --- a/ebike-maintenance/pages/devops/bikesite/bikesite-info.vue +++ b/ebike-maintenance/pages/devops/bikesite/bikesite-info.vue @@ -1,71 +1,74 @@ diff --git a/ebike-maintenance/utils/map.js b/ebike-maintenance/utils/map.js index 91ec1f0..fd9026b 100644 --- a/ebike-maintenance/utils/map.js +++ b/ebike-maintenance/utils/map.js @@ -316,7 +316,7 @@ export function getRegionData(arrRegionID, callback) { arrCircles.push(addCirle(scolor, fcolor, lng, lat, radius)); arrCirclesData.push(data); } else if (shapeType == 2) { - if(!points) return; + if (!points) return; const arrPoint = points.map(p => { return { longitude: p.longitude, @@ -365,6 +365,7 @@ export const getBikeData = (arrRegionID, callback) => { } else { if (data.length > 0) arrData.push(...data); data.map(item => { + item={...item,soc:item.soc||0} const { bikeId, longitude, @@ -396,7 +397,7 @@ export const getBikeData = (arrRegionID, callback) => { //电量车辆点 export function addMarker_Q(id, data) { - const { + let { longitude, latitude, soc @@ -480,76 +481,6 @@ export function direction({ qqmapsdk.direction(options); } -// 几何中心计算算法(适用于任意多边形) -export function getPolygonCenter(points) { - let X = 0, - Y = 0, - Z = 0; - const pointCount = points.length; - - points.forEach(point => { - const lat = point.latitude * Math.PI / 180; - const lng = point.longitude * Math.PI / 180; - const x = Math.cos(lat) * Math.cos(lng); - const y = Math.cos(lat) * Math.sin(lng); - const z = Math.sin(lat); - - X += x; - Y += y; - Z += z; - }); - - X /= pointCount; - Y /= pointCount; - Z /= pointCount; - - const lng = Math.atan2(Y, X); - const lat = Math.atan2(Z, Math.sqrt(X * X + Y * Y)); - - return { - lat: lat * 180 / Math.PI, - lng: lng * 180 / Math.PI - }; -} - - -// 工具函数:将像素坐标转换为经纬度 -function pixelToLatLng(map, x, y) { - // return new Promise((resolve) => { - // map.getCenterLocation({ - // success: (res) => { - // const center = { lat: res.latitude, lng: res.longitude }; - // const scale = map.scale; - // const pixelWidth = 256 * Math.pow(2, (18 - scale)); // 缩放级别对应的像素宽度 - // const latOffset = (y - map.height / 2) * (180 / (256 * Math.pow(2, scale))) / 3600; - // const lngOffset = (x - map.width / 2) * (180 / (256 * Math.pow(2, scale))) / 3600; - // resolve({ - // latitude: center.lat + latOffset, - // longitude: center.lng + lngOffset - // }); - // } - // }); - // }); -} - -// 计算可视区域四个角点 -export function calculateVisibleBounds(map) { - map.getScale((res) => { - console.log("00000000000000000000", res) - }) - - // const topLeft = await pixelToLatLng(map, 0, 0); - // const topRight = await pixelToLatLng(map, width, 0); - // const bottomLeft = await pixelToLatLng(map, 0, height); - // const bottomRight = await pixelToLatLng(map, width, height); - - // return { - // minLat: Math.min(topLeft.latitude, bottomLeft.latitude), - // maxLat: Math.max(topRight.latitude, bottomRight.latitude), - // minLng: Math.min(topLeft.longitude, topRight.longitude), - // maxLng: Math.max(bottomLeft.longitude, bottomRight.longitude) - // }; -} // 判断点是否在多边形内(射线法) export function checkPointInPolygon(longitude, latitude, polygon) { @@ -572,7 +503,6 @@ export function checkPointInPolygon(longitude, latitude, polygon) { // 判断点(x,y)是否在圆心(cx,cy)半径r的圆内 export function isPointInCircle(longitude, latitude, center, radius) { - debugger; const dx = longitude - center.lng; // 经度差 const dy = latitude - center.lat; // 纬度差 const distance = Math.sqrt(dx * dx + dy * dy);