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

微信小程序 獲取當(dāng)前地理位置和經(jīng)緯度實(shí)例代碼

 更新時(shí)間:2016年12月05日 14:51:02   作者:韓天偉  
這篇文章主要介紹了微信小程序 獲取當(dāng)前地理位置和經(jīng)緯度實(shí)例代碼的相關(guān)資料,這里附有實(shí)例代碼,及實(shí)現(xiàn)效果圖,需要的朋友可以參考下

微信小程序?qū)嵗?獲取當(dāng)前的地理位置、經(jīng)緯度

微信小程序官方文檔

https://mp.weixin.qq.com/debug/wxadoc/dev/api/location.html

JS代碼

//index.js
//獲取應(yīng)用實(shí)例
var app = getApp()
Page({
 data: {
  motto: '示例小程序-獲取當(dāng)前地理位、速度',
  userInfo: {},
  hasLocation:false,
  location:{}
 },
 //事件處理函數(shù)
 bindViewTap: function() {
  wx.navigateTo({
   url: '../logs/logs'
  })
 },
 onLoad: function () {
  console.log('onLoad')
  var that = this
  //調(diào)用應(yīng)用實(shí)例的方法獲取全局?jǐn)?shù)據(jù)
  app.getUserInfo(function(userInfo){
   //更新數(shù)據(jù)
   that.setData({
    userInfo:userInfo
   })
  }),
   wx.getLocation( {
   success: function( res ) {
    console.log( res )
    that.setData( {
     hasLocation: true,
     location: {
      longitude: res.longitude,
      latitude: res.latitude
     }
    })
   }
  })
 }
})

index.wxml

<!--index.wxml-->
<view class="container">
 <view bindtap="bindViewTap" class="userinfo">
  <image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>
  <text class="userinfo-nickname">{{userInfo.nickName}}</text>
 </view>
 <view class="usermotto">
  <!-- <text class="user-motto">{{motto}}\n</text>-->
  <text>經(jīng)度:{{location.longitude}}\n</text>
  <text>緯度:{{location.latitude}}</text>
 </view>
</view>

運(yùn)行效果

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

相關(guān)文章

最新評(píng)論

阿瓦提县| 阿合奇县| 兴和县| 宁波市| 衡南县| 东莞市| 海林市| 教育| 光山县| 济源市| 民县| 威宁| 阳新县| 广西| 濉溪县| 大理市| 岳西县| 西林县| 徐州市| 集安市| 辛集市| 桐城市| 绍兴县| 香河县| 芜湖县| 定兴县| 咸阳市| 阿城市| 西乡县| 宣威市| 漯河市| 河西区| 莎车县| 奉节县| 敦化市| 通州市| 皮山县| 福海县| 梓潼县| 墨脱县| 龙口市|