1. 程式人生 > >微信小程式地圖導航

微信小程式地圖導航

<map id="map" longitude="116.48834"latitude="39.91692"scale="14" controls="{{controls}}" bindcontroltap="controltap" markers="{{markers}}" bindmarkertap="markertap" polyline="{{polyline}}" bindregionchange="regionchange" show-location style="width: 100%; height: 300px;"></map> <view class
="dh"><buttonbindtap="openMap">開始導航</button></view> data: { userNum:'', markers: [{ iconPath:"/wximages/location.png", id: 0, latitude:39.91692, longitude:116.48834, width: 20, height: 30 }], } openMap: function () { wx.openLocation({ latitude:39.91692, longitude:116.48834, scale: 14
, name:'xxxxxxxxxxx', address:'xxxxxxxxxxx' }) }, openMap: function () { wx.getLocation({ type: 'gcj02',//返回可以用於wx.openLocation的經緯度 success: function (res) { console.log(res) var latitude = res.latitude var longitude = res.longitude wx.openLocation({ latitude: latitude, longitude: longitude, scale: 28
, name: 'xxxxxxxxxxx', address: 'xxxxxxxxxxx' }) } }) },