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