最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序3種位置API的使用方法詳解

 更新時(shí)間:2019年08月05日 16:35:18   作者:dq_095  
這篇文章主要介紹了微信小程序3種位置API的使用方法詳解,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下

獲取位置

獲取當(dāng)前的地理位置、速度。當(dāng)用戶離開小程序后,此接口無法調(diào)用;當(dāng)用戶點(diǎn)擊“顯示在聊天頂部”時(shí),此接口可繼續(xù)調(diào)用。

wx.getLocation(object)

<view class="container">
 <button bindtap='getLocation'>獲取位置</button>
 <view wx:if="{{latitude !=''}}">
  <view>緯度:{{latitude}}</view>
  <view>經(jīng)度:{{longitude}}</view>
  <view>速度:{{speed}}</view>
  <view>位置的精確度:{{accuracy}}</view>
  <view>高度:{{altitude}}</view>
  <view>垂直精度:{{accuracy}}</view>
  <view>水平精度:{{accuracy}}</view>
 </view>
</view>
//index.js
//獲取應(yīng)用實(shí)例
const app = getApp()
Page({
 data: {
  latitude: '',
  longitude: '',
  speed: '',
  accuracy: '',
  altitude:'',
  verticalAccuracy: '',
  horizontalAccuracy:''
 },
 onLoad: function () {
 },
 getLocation:function(){
  var _this=this;
  wx.getLocation({
   type: 'wgs84',
   success: function (res) {
    var latitude = res.latitude
    var longitude = res.longitude
    var speed = res.speed
    var accuracy = res.accuracy
    var altitude = res.altitude
    var verticalAccuracy = res.verticalAccuracy
    var horizontalAccuracy = res.horizontalAccuracy
    _this.setData({
     latitude: latitude,
     longitude: longitude,
     speed: speed,
     accuracy: accuracy,
     altitude: altitude,
     verticalAccuracy: verticalAccuracy,
     horizontalAccuracy: horizontalAccuracy
    })
   }
  })
 }
})

打開地圖選擇位置

wx.chooseLocation(OBJECT)

打開地圖選擇位置。

需要用戶授權(quán) scope.userLocation

wx.chooseLocation(object)

<view class="container">
 <button bindtap='getLocation'>打開地圖選擇位置</button>
 <view wx:if="{{address !=''}}">
  <view>位置名稱:{{name}}</view>
  <view>詳細(xì)地址:{{address}}</view>
  <view>緯度:{{latitude}}</view>
  <view>經(jīng)度:{{longitude}}</view>
 </view>
</view>
//index.js
//獲取應(yīng)用實(shí)例
const app = getApp()
Page({
 data: {
  name: '',
  address: '',
  latitude: '',
  longitude: ''
 },
 onLoad: function () {
 },
 getLocation:function(){
  var _this=this;
  wx.chooseLocation({
   success: function (res) {
    var name = res.name
    var address = res.address
    var latitude = res.latitude
    var longitude = res.longitude
    _this.setData({
     name: name,
     address: address,
     latitude: latitude,
     longitude: longitude
    })
   }
  })
 }
})

​使用微信內(nèi)置地圖查看位置

使用微信內(nèi)置地圖查看位置。

wx.openLocation(OBJECT)

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

舒城县| 上蔡县| 屯门区| 资兴市| 汝阳县| 尚志市| 四川省| 鄂伦春自治旗| 黄平县| 湘乡市| 遵化市| 巴彦县| 于都县| 顺义区| 体育| 开鲁县| 苍南县| 邯郸市| 福清市| 南城县| 晋宁县| 南开区| 拉孜县| 盐池县| 和顺县| 皋兰县| 忻州市| 石渠县| 玉门市| 平陆县| 江川县| 巫溪县| 神农架林区| 额敏县| 张北县| 昭平县| 三都| 沙河市| 乌拉特后旗| 班玛县| 崇礼县|