微信小程序地图导航

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_40292626/article/details/78677676
<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'
})
}
})
},

没有更多推荐了,返回首页