fix: 修正一下bug

This commit is contained in:
fengyarnom 2025-06-11 16:56:54 +08:00
parent a2f2e837d9
commit 427b38c8f1

View File

@ -34,13 +34,13 @@
}
.top-panel-number {
/* line-height: 60px; // 删除或注释掉这一行 */
/* line-height: 60px; */
font-size: 30px;
border-right: 1px solid #eceff9;
height: 100%;
display: flex;
align-items: center;
justify-content: center; /* 可选:让数字水平居中 */
justify-content: center;
}
.top-panel-tips{
line-height:30px;
@ -153,7 +153,7 @@
<body>
<div class="layuimini-main">
<div class="layui-row layui-col-space30 flex-row" style="margin-bottom: 2em;">
<div class="layui-row layui-col-space30 flex-row" style="margin-bottom: 1em;">
<div class="layui-col-xs12 layui-col-md6">
<div class="layui-card top-panel stats-panel">
<div class="layui-card-header">设备数量</div>
@ -399,24 +399,19 @@
currentBaseLayer = mapLayers[mapType];
map.getLayers().insertAt(0, currentBaseLayer);
// 更新我的位置标记,使用正确的坐标系
updateMyLocationForMapType(mapType);
// 更新设备标记
addDeviceMarkers();
}
// 根据地图类型更新我的位置标记
function updateMyLocationForMapType(mapType) {
if (myLocationFeature) {
// 获取原始坐标
var originalCoords = myLocationFeature.get('originalCoords');
if (originalCoords) {
var lat = originalCoords.lat;
var lon = originalCoords.lon;
var coordinates;
// 根据地图类型进行坐标转换
if (mapType === 'amap' || mapType === 'amap_satellite') {
// 高德地图使用GCJ-02坐标系需要转换
var gcjCoord = transform(lat, lon);
@ -426,17 +421,14 @@
coordinates = ol.proj.fromLonLat([lon, lat]);
}
// 更新位置标记的几何坐标
myLocationFeature.getGeometry().setCoordinates(coordinates);
}
}
}
function addDeviceMarkers() {
// 保存我的位置标记
var savedMyLocationFeature = myLocationFeature;
// 清除现有标记
vectorSource.clear();
greenFeatures = [];
orangeFeatures = [];