65 lines
1.2 KiB
JavaScript
Raw Normal View History

2025-04-15 19:03:32 +08:00
import config from "./config.js";
const imgPath=config.imgPath;
export const sdkKey = 'BECBZ-EJIEQ-LUU5N-B5ISQ-3TLMZ-BXFLG';
//获取当前定位
export function getLoalcation ( success, fail) {
uni.getLocation({
type: 'gcj02', // 返回可以用于 wx.openLocation 的经纬度
geocode: true,
success(res) {
const {
latitude,
longitude
} = res;
if (success) success({
latitude,
longitude
});
},
fail(res) {
if (fail) fail(res);
}
});
}
//逆解析地址
export function reverseGeocoder (qqmapsdk, longitude, latitude, success, fail) {
qqmapsdk.reverseGeocoder({
location: {
latitude: latitude,
longitude: longitude
},
success: (res) => {
if (success) success(res.result);
},
fail: (res) => {
if (fail) success(fail);
}
})
}
//添加点
export function addMarker(id, longitude, latitude, icon, joinCluster) {
return {
id: id,
latitude,
longitude,
width: 30,
height: 30,
zIndex: "100",
iconPath: imgPath+"static/userui/home/" + icon,
joinCluster: joinCluster ? true : false
};
}
//添加线
export function addLine(scolor, arrPoints) {
return {
points: arrPoints,
color: scolor,
width: 3
}
}