fix(首页): 优化百度地图为3.0

This commit is contained in:
yang
2026-02-02 16:51:51 +08:00
parent 49dfb323c8
commit ef724814a0
3 changed files with 252 additions and 251 deletions

View File

@@ -18,11 +18,12 @@ export function loadBMap() {
document.head.appendChild(meta)
}
// 引入百度地图
let script = document.createElement('script')
script.type = 'text/javascript'
script.src =
'http://api.map.baidu.com/api?v=2.0&ak='+ process.env.VUE_APP_BAI_DU_AK +'&s=1&__ec_v__=20190126&callback=onBMapCallback'
script.onerror = reject
document.head.appendChild(script)
const script = document.createElement('script');
const ak = process.env.VUE_APP_BAI_DU_AK
script.type = 'text/javascript';
script.src = `https://api.map.baidu.com/api?v=3.0&ak=${ak}&callback=onBMapCallback`;
script.onerror = reject;
document.head.appendChild(script);
})
}

View File

@@ -161,130 +161,130 @@ export default {
zoom: 5,
// 大屏用zomm缩放导致地图缩放中心点会偏移
roam: 'move',
mapStyle: {
styleJson: [{
featureType: 'water',
elementType: 'all',
stylers: {
color: '#3863db'
}
},
{
featureType: 'land',
elementType: 'all',
stylers: {
color: '#0e2e87'
}
},
{
featureType: 'railway',
elementType: 'all',
stylers: {
visibility: 'off'
}
},
{
featureType: 'highway',
elementType: 'all',
stylers: {
visibility: 'off',
color: '#fdfdfd'
}
},
{
featureType: 'highway',
elementType: 'labels',
stylers: {
visibility: 'off',
visibility: 'off'
}
},
{
featureType: 'arterial',
elementType: 'geometry',
stylers: {
visibility: 'off',
color: '#fefefe'
}
},
{
featureType: 'arterial',
elementType: 'geometry.fill',
stylers: {
visibility: 'off',
color: '#fefefe'
}
},
{
featureType: 'poi',
elementType: 'all',
stylers: {
visibility: 'off',
visibility: 'off'
}
},
{
featureType: 'green',
elementType: 'all',
stylers: {
visibility: 'off'
}
},
{
featureType: 'subway',
elementType: 'all',
stylers: {
visibility: 'off'
}
},
{
featureType: 'manmade',
elementType: 'all',
stylers: {
visibility: 'off',
color: '#d1d1d1'
}
},
{
featureType: 'local',
elementType: 'all',
stylers: {
visibility: 'off',
color: '#d1d1d1'
}
},
{
featureType: 'arterial',
elementType: 'labels',
stylers: {
visibility: 'off'
}
},
{
featureType: 'boundary',
elementType: 'all',
stylers: {
color: '#23cdd8'
}
},
{
featureType: 'building',
elementType: 'all',
stylers: {
visibility: 'off',
color: '#d1d1d1'
}
},
{
featureType: 'label',
elementType: 'labels.text.fill',
stylers: {
color: '#264194',
visibility: 'off'
}
}
]
}
// mapStyle: {
// styleJson: [{
// featureType: 'water',
// elementType: 'all',
// stylers: {
// color: '#3863db'
// }
// },
// {
// featureType: 'land',
// elementType: 'all',
// stylers: {
// color: '#0e2e87'
// }
// },
// {
// featureType: 'railway',
// elementType: 'all',
// stylers: {
// visibility: 'off'
// }
// },
// {
// featureType: 'highway',
// elementType: 'all',
// stylers: {
// visibility: 'off',
// color: '#fdfdfd'
// }
// },
// {
// featureType: 'highway',
// elementType: 'labels',
// stylers: {
// visibility: 'off',
// visibility: 'off'
// }
// },
// {
// featureType: 'arterial',
// elementType: 'geometry',
// stylers: {
// visibility: 'off',
// color: '#fefefe'
// }
// },
// {
// featureType: 'arterial',
// elementType: 'geometry.fill',
// stylers: {
// visibility: 'off',
// color: '#fefefe'
// }
// },
// {
// featureType: 'poi',
// elementType: 'all',
// stylers: {
// visibility: 'off',
// visibility: 'off'
// }
// },
// {
// featureType: 'green',
// elementType: 'all',
// stylers: {
// visibility: 'off'
// }
// },
// {
// featureType: 'subway',
// elementType: 'all',
// stylers: {
// visibility: 'off'
// }
// },
// {
// featureType: 'manmade',
// elementType: 'all',
// stylers: {
// visibility: 'off',
// color: '#d1d1d1'
// }
// },
// {
// featureType: 'local',
// elementType: 'all',
// stylers: {
// visibility: 'off',
// color: '#d1d1d1'
// }
// },
// {
// featureType: 'arterial',
// elementType: 'labels',
// stylers: {
// visibility: 'off'
// }
// },
// {
// featureType: 'boundary',
// elementType: 'all',
// stylers: {
// color: '#23cdd8'
// }
// },
// {
// featureType: 'building',
// elementType: 'all',
// stylers: {
// visibility: 'off',
// color: '#d1d1d1'
// }
// },
// {
// featureType: 'label',
// elementType: 'labels.text.fill',
// stylers: {
// color: '#264194',
// visibility: 'off'
// }
// }
// ]
// }
},
series: [{
type: 'scatter',

View File

@@ -339,11 +339,11 @@ export default {
},
/**加载地图*/
loadMap() {
this.$nextTick(() => {
loadBMap().then(() => {
this.getmap();
});
});
setTimeout(() => {
this.getmap(); // 里面有 setOption
}, 500);
})
},
/** 查询服务器信息 */
getServer() {
@@ -494,122 +494,122 @@ export default {
center: [133, 38],
zoom: 5,
roam: true,
mapStyle: {
styleJson: [
{
featureType: 'water',
elementType: 'all',
stylers: {
color: '#a0cfff',
},
},
{
featureType: 'land',
elementType: 'all',
stylers: {
color: '#fafafa', // #fffff8 淡黄色
},
},
{
featureType: 'railway',
elementType: 'all',
stylers: {
visibility: 'off',
},
},
{
featureType: 'highway',
elementType: 'all',
stylers: {
color: '#fdfdfd',
},
},
{
featureType: 'highway',
elementType: 'labels',
stylers: {
visibility: 'off',
},
},
{
featureType: 'arterial',
elementType: 'geometry',
stylers: {
color: '#fefefe',
},
},
{
featureType: 'arterial',
elementType: 'geometry.fill',
stylers: {
color: '#fefefe',
},
},
{
featureType: 'poi',
elementType: 'all',
stylers: {
visibility: 'off',
},
},
{
featureType: 'green',
elementType: 'all',
stylers: {
visibility: 'off',
},
},
{
featureType: 'subway',
elementType: 'all',
stylers: {
visibility: 'off',
},
},
{
featureType: 'manmade',
elementType: 'all',
stylers: {
color: '#d1d1d1',
},
},
{
featureType: 'local',
elementType: 'all',
stylers: {
color: '#d1d1d1',
},
},
{
featureType: 'arterial',
elementType: 'labels',
stylers: {
visibility: 'off',
},
},
{
featureType: 'boundary',
elementType: 'all',
stylers: {
color: '#999999',
},
},
{
featureType: 'building',
elementType: 'all',
stylers: {
color: '#d1d1d1',
},
},
{
featureType: 'label',
elementType: 'labels.text.fill',
stylers: {
color: '#999999',
},
},
],
},
// mapStyle: {
// styleJson: [
// {
// featureType: 'water',
// elementType: 'all',
// stylers: {
// color: '#a0cfff',
// },
// },
// {
// featureType: 'land',
// elementType: 'all',
// stylers: {
// color: '#fafafa', // #fffff8 淡黄色
// },
// },
// {
// featureType: 'railway',
// elementType: 'all',
// stylers: {
// visibility: 'off',
// },
// },
// {
// featureType: 'highway',
// elementType: 'all',
// stylers: {
// color: '#fdfdfd',
// },
// },
// {
// featureType: 'highway',
// elementType: 'labels',
// stylers: {
// visibility: 'off',
// },
// },
// {
// featureType: 'arterial',
// elementType: 'geometry',
// stylers: {
// color: '#fefefe',
// },
// },
// {
// featureType: 'arterial',
// elementType: 'geometry.fill',
// stylers: {
// color: '#fefefe',
// },
// },
// {
// featureType: 'poi',
// elementType: 'all',
// stylers: {
// visibility: 'off',
// },
// },
// {
// featureType: 'green',
// elementType: 'all',
// stylers: {
// visibility: 'off',
// },
// },
// {
// featureType: 'subway',
// elementType: 'all',
// stylers: {
// visibility: 'off',
// },
// },
// {
// featureType: 'manmade',
// elementType: 'all',
// stylers: {
// color: '#d1d1d1',
// },
// },
// {
// featureType: 'local',
// elementType: 'all',
// stylers: {
// color: '#d1d1d1',
// },
// },
// {
// featureType: 'arterial',
// elementType: 'labels',
// stylers: {
// visibility: 'off',
// },
// },
// {
// featureType: 'boundary',
// elementType: 'all',
// stylers: {
// color: '#999999',
// },
// },
// {
// featureType: 'building',
// elementType: 'all',
// stylers: {
// color: '#d1d1d1',
// },
// },
// {
// featureType: 'label',
// elementType: 'labels.text.fill',
// stylers: {
// color: '#999999',
// },
// },
// ],
// },
},
series: [
{