2025年04月29日09:47:14
This commit is contained in:
parent
20aa050e75
commit
49ae2970bf
@ -106,17 +106,12 @@ export class MapCustom {
|
||||
newIcon(option) {
|
||||
let data = {
|
||||
size: new AMap.Size(36, 42),
|
||||
image: '', // Icon的图像
|
||||
image: option.image, // Icon的图像
|
||||
imageSize: new AMap.Size(36, 42)
|
||||
}
|
||||
if (typeof option == 'string') {
|
||||
data.image = option
|
||||
} else {
|
||||
data = {
|
||||
image: option.image, // Icon的图像
|
||||
size: new AMap.Size(option.size[0], option.size[1]),
|
||||
imageSize: new AMap.Size(option.size[0], option.size[1]),
|
||||
}
|
||||
if (option.size) {
|
||||
data.size = new AMap.Size(option.size[0], option.size[1])
|
||||
data.imageSize = new AMap.Size(option.size[0], option.size[1])
|
||||
}
|
||||
return new AMap.Icon({ ...data })
|
||||
}
|
||||
@ -131,13 +126,14 @@ export class MapCustom {
|
||||
lngLat(lng, lat) {
|
||||
return new AMap.LngLat(lng, lat);
|
||||
}
|
||||
infoWindow(option = {
|
||||
anchor: 'bottom-center',
|
||||
isCustom: true, //使用自定义窗体
|
||||
content: document.querySelector('.infoBox'),
|
||||
offset: new AMap.Pixel(-2, -40),
|
||||
}) {
|
||||
return new AMap.InfoWindow(option)
|
||||
infoWindow(option) {
|
||||
return new AMap.InfoWindow({
|
||||
anchor: 'bottom-center',
|
||||
isCustom: true,
|
||||
content: document.querySelector('.infoBox'),
|
||||
offset: new AMap.Pixel(-2, -40),
|
||||
...option
|
||||
})
|
||||
|
||||
}
|
||||
//绘制轨迹线条
|
||||
|
@ -281,7 +281,7 @@ const getData = async () => {
|
||||
|
||||
map.clearMap();
|
||||
map.setCenter([res.lng, res.lat]);
|
||||
let icon = map.newIcon(location);
|
||||
let icon = map.newIcon({ image: location });
|
||||
let marker = map.marker({ icon, position: [res.lng, res.lat] });
|
||||
marker.setMap(map.map);
|
||||
marker.on("click", () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user