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

发布: 2019-12-18 17:41:45标签: 前端开发

地图图片

01export function mapSrc({ width = 500, height = 300, lat = "", lng = "" }) {
02 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 ||
03 116.397428},${lat || 39.90923}&key=517823f8f1d25adffabba46df2a374eb`;
04}
复制代码

打开地图

01export function openMap({ lat, lng } = {}) {
02 // if (isWx) {
03 // return openLocation({
04 // latitude: lat, // 纬度,浮点数,范围为90 ~ -90
05 // longitude: lng
06 // });
07 // }
08 const url = `https://uri.amap.com/marker?position=${lng ||
09 116.397428},${lat || 39.90923}&name=婚礼地址`;
10 window.location.href = url;
11}
复制代码