wxml部分
<text class="map_btn" bindtap="openMap" data-latitude='{{latitude}}' data-longitude='{{longitude}}' data-addressName='{{addmissage}}'>地图/导航</text>
js部分
Page({
/**
* 页面的初始数据
*/
data: {
addmissage: '郑州市中原区纪检委',
latitude: "34.74821",
longitude: "113.61332"
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
openMap:function(res){
var lat = Number(res.currentTarget.dataset.latitude);
var lon = Number(res.currentTarget.dataset.longitude);
var addressName = res.currentTarget.dataset.addressName;
console.log(lat);
console.log(lon);
wx.openLocation({
type: 'gcj02',
latitude: lat,
longitude: lon,
name: addressName,
scale: 28
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
这样可直接调起本机的导航选项