作者 小范

车辆定位重叠问题优化

@@ -113,6 +113,11 @@ @@ -113,6 +113,11 @@
113 // 获取车辆位置信息 113 // 获取车辆位置信息
114 const vehicle = res.data.data.firstVcl; 114 const vehicle = res.data.data.firstVcl;
115 // 在获取车辆位置成功的部分,创建信息窗口或者自定义标记 115 // 在获取车辆位置成功的部分,创建信息窗口或者自定义标记
  116 +
  117 + if (vehicle.lon && vehicle.lat) {
  118 + const lon = parseFloat(vehicle.lon) / 600000.0; // 将经度字符串转换为数值并除以 600000.0
  119 + const lat = parseFloat(vehicle.lat) / 600000.0; // 将纬度字符串转换为数值并除以 600000.0
  120 + //const coords = wgs84togcj02(lon, lat);
116 const markerContent = document.createElement('div'); 121 const markerContent = document.createElement('div');
117 markerContent.innerHTML = ` 122 markerContent.innerHTML = `
118 <div class="rounded-corner" STYLE="width: 200px;background-color: rgba(255,255,255,0.7);text-align: center"> 123 <div class="rounded-corner" STYLE="width: 200px;background-color: rgba(255,255,255,0.7);text-align: center">
@@ -121,10 +126,6 @@ @@ -121,10 +126,6 @@
121 <p>剩余距离:${vehicle.remainDistance}公里</p > 126 <p>剩余距离:${vehicle.remainDistance}公里</p >
122 </div> 127 </div>
123 `; 128 `;
124 - if (vehicle.lon && vehicle.lat) {  
125 - const lon = parseFloat(vehicle.lon) / 600000.0; // 将经度字符串转换为数值并除以 600000.0  
126 - const lat = parseFloat(vehicle.lat) / 600000.0; // 将纬度字符串转换为数值并除以 600000.0  
127 - //const coords = wgs84togcj02(lon, lat);  
128 // 添加车辆位置标记 129 // 添加车辆位置标记
129 const marker = new AMap.Marker({ 130 const marker = new AMap.Marker({
130 position: [lon, lat], 131 position: [lon, lat],