H5地图导航
腾讯地图
window.location.href = http://apis.map.qq.com/uri/v1/marker?marker=coord:lat,lng;addr:address
其中lat、lng、address分别为经纬度和详细地址三个参数
小程序、app
uni.openLocation({
latitude: lat-0,//要去的纬度-地址
longitude: lon-0,//要去的经度-地址
name: e,//地址名称
address: e,//详细地址名称
success: function () {
console.log('导航成功');
},
fail:function(error){
console.log(error)
}
});
这里的lat-0和lon-0是因为你获取的经纬度是string类型的,uni.openLocation需要的参数类型是number类型的
如果同一个项目需要同时用到H5导航、小程序、app可以用一下方法区分:
只能用于app
// #ifdef APP-PLUS
//#endif
小程序 app
//#ifndef H5