<
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"><
button
bindtap=
"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'
})
}
})
},