uni.openLocation usage problem
Environment : uni-app develops H5 projects, and the H5 project link webview is embedded in the app
Purpose : Open the map location of the target and navigate. After the navigation is completed, exit and return to the original interface
. Problem :
- Only the target location can be passed in, and you need to click Position and then click Navigation to start navigation.
- Clicking the navigation directly can only select the default starting point, and cannot return to the optional locations based on the current location.
- When the navigation is completed and clicked to return, the return will be invalid on the IOS phone.
Solution : Do not use this API, modify the current path to the map page path and navigate directly
openLocation(e) {
const { latitude, longitude, address } = e.currentTarget.dataset;
if (latitude && longitude) {
// #ifdef H5
let url = `https://apis.map.qq.com/tools/routeplan/eword=${address}&epointx=${latitude}&epointy=${longitude}?referer=${应用名称}&key=${腾讯地图的key}`
window.location.href = url
// #endif
// #ifdef MP-WEIXIN
uni.openLocation({
latitude: Number(latitude),
longitude: Number(longitude),
name: address || ''
});
// #endif
}
},