// 导航
navigation() {
var that = this;
var qqmapsdk = new amapFile({
key: 'key值'
});
let name = this.data.address
let address = this.data.address
qqmapsdk.geocoder({
address: address,
success: function (res) {
// 经度lng 纬度lat
let latitude = res.result.location.lat
let longitude = res.result.location.lng
// console.log(res,'res')
wx.getLocation({ //获取当前经纬度
type: 'wgs84', //返回可以用于wx.openLocation的经纬度,官方提示bug: iOS 6.3.30 type 参数不生效,只会返回 wgs84 类型的坐标信息
success: function (res) {
// console.log(res,'res2')
// console.log(latitude,'latitude')
// console.log(longitude,'longitude')
wx.openLocation({ //使用微信内置地图查看位置。
latitude: latitude, //要去的纬度-地址
longitude: longitude, //要去的经度-地址
name: name,
address: address,
scale: 18
})
},
fail:function(res){
if(res.errMsg=="getLocation:fail auth deny"){
that.showSettingToast()
}
}
})
},
complete: res => {
// console.log(res.result.location)
}
})
},
showSettingToast: function(e) {
// console.log("1")
wx.showModal({
title: '提示!',
showCancel: true,
content: '未开启定位,是否去设置',
success: function(res) {
// console.log(res,'res')
if (res.confirm) {
wx.navigateTo({
url: '../setting/setting',
})
}
}
})
},
setting页的代码
<view class="tips">请配置微信设置功能</view>
<button open-type="openSetting" type="primary">
<view class="img">
<image src="../../images/setting.png">
</image>
</view>设置
</button>
/* pages/setting/setting.wxss */
.tips{
font-size:32rpx;
color: #666666;
padding: 24rpx 48rpx 120rpx;
}
button{
padding: 0;
width:420rpx !important;
height:76rpx !important;
/* line-height: 76rpx; */
background:#0DAABF !important;
border-radius:18rpx !important;
display: flex;
align-items: center;
justify-content: center;
}
.img{
width: 34rpx;
height: 34rpx;
margin-right: 18rpx;
}
image{
width: 100%;
height: 100%;
vertical-align: top;
/* margin-top: 20rpx !important; */
}