两个直接可以用的高德地图api

地图图片

1
2
3
4
export function mapSrc({ width = 500, height = 300, lat = "", lng = "" }) {
return `http://restapi.amap.com/v3/staticmap?&zoom=17&scale=2&size=${width}*${height}&markers=-1,https://img1.halobear.com/invitation/mark.png,0:${lng ||
116.397428},${lat || 39.90923}&key=517823f8f1d25adffabba46df2a374eb`;
}

打开地图

1
2
3
4
5
6
7
8
9
10
11
export function openMap({ lat, lng } = {}) {
// if (isWx) {
// return openLocation({
// latitude: lat, // 纬度,浮点数,范围为90 ~ -90
// longitude: lng
// });
// }
const url = `https://uri.amap.com/marker?position=${lng ||
116.397428},${lat || 39.90923}&name=婚礼地址`;
window.location.href = url;
}