成熟丰满熟妇高潮XXXXX,人妻无码AV中文系列久久兔费 ,国产精品一国产精品,国精品午夜福利视频不卡麻豆

您好,歡迎來到九壹網(wǎng)。
搜索
您的當(dāng)前位置:首頁微信小程序?qū)崿F(xiàn)定位及到指定位置導(dǎo)航的示例代碼

微信小程序?qū)崿F(xiàn)定位及到指定位置導(dǎo)航的示例代碼

來源:九壹網(wǎng)

一:實現(xiàn)定位及到指定位置導(dǎo)航所需組件及API

1:組件:map(地圖組件)

2:API:wx.getLocation(Object object)(獲取當(dāng)前的地理位置、速度),wx.openLocation(Object object)(使用微信內(nèi)置地圖查看位置)

二:代碼實現(xiàn)

1:wxml

<view>
<map id="map"
longitude="{{longitude}}"
latitude="{{latitude}}"
scale="14"
markers="{{markers}}"
bindmarkertap="markertap"
bindregionchange="regionchange"
show-location
style="width: 100%; height: 300px;"
>
</map>
</view>
<view>
<button type="primary" bindtap="navigate">導(dǎo)航</button>
</view>

2:js

//js
Page({
/**
 * 頁面的初始數(shù)據(jù)
 */
data: {
//設(shè)置標(biāo)記點
markers: [
{
iconPath: "/images/ljx.png",
id: 4,
latitude: 31.938841,
longitude: 118.799698,
width: 30,
height: 30
}
],
//當(dāng)前定位位置
latitude:'',
longitude: '',
},
navigate() {
////使用微信內(nèi)置地圖查看標(biāo)記點位置,并進(jìn)行導(dǎo)航
wx.openLocation({
latitude: this.data.markers[0].latitude,//要去的緯度-地址
longitude: this.data.markers[0].longitude,//要去的經(jīng)度-地址
})
},
onLoad() {
//獲取當(dāng)前位置
wx.getLocation({
type: 'gcj02',
success: (res) => {
console.log(res)
this.setData({
latitude: res.latitude,
longitude: res.longitude
})
}
})
}
})

根據(jù)如上即可實現(xiàn)自身定位及到指定位置的導(dǎo)航,如下:




Copyright ? 2019- 91gzw.com 版權(quán)所有 湘ICP備2023023988號-2

違法及侵權(quán)請聯(lián)系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市萬商天勤律師事務(wù)所王興未律師提供法律服務(wù)