欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序 location API實例詳解

 更新時間:2016年10月02日 09:44:35   作者:順子_RTFSC  
這篇文章主要介紹了微信小程序 location API實例詳解的相關(guān)資料,需要的朋友可以參考下

location API也就分這里分兩種wx.getLocation(object)獲取當(dāng)前位置和wx.openLocation(object)通過經(jīng)緯度打開內(nèi)置地圖。其中定位獲取位置信息返回參數(shù)是有問題的speed,accuracy這兩個是沒有的。還有一個就是打開內(nèi)置地圖之后再返回會報一個錯誤(Page route錯誤—WAService.js:2 navigateBack 一個不存在的webviewId0)如果有知道的可告知,我找到解決方式也會補充下!

主要屬性:

wx.getLocation(object)獲取當(dāng)前位置

成功之后返回參數(shù)

wx.openLocation(object)打開微信內(nèi)置地圖

這里直接進入微信內(nèi)置應(yīng)用,當(dāng)使用導(dǎo)航返回鍵時是內(nèi)部寫的外界無法干預(yù)所以WAService.js:2 navigateBack 一個不存在的webviewId0這個錯估計也帶等小程序修復(fù)吧??!

wxml

<button id="0" type="primary" bindtap="listenerBtnGetLocation">定位當(dāng)前位置并打開內(nèi)置地圖</button>

js

Page({
 data:{
  text:"Page location"
 },
 onLoad:function(options){
  // 頁面初始化 options為頁面跳轉(zhuǎn)所帶來的參數(shù)
 },

 /**
  * 監(jiān)聽定位到當(dāng)前位置
  */
 listenerBtnGetLocation: function() {
  wx.getLocation({
   //定位類型 wgs84, gcj02
   type: 'gcj02',
   success: function(res) {
    console.log(res)
    wx.openLocation({
     //當(dāng)前經(jīng)緯度
     latitude: res.latutude,
     longitude: res.longitude,
     //縮放級別默認28
     scale: 28,
     //位置名
     name: '測試地址',
     //詳細地址
     address: '火星路24號',
     //成功打印信息
     success: function(res) {
      console.log(res)
     },
     //失敗打印信息
     fail: function(err) {
      console.log(err)
     },
     //完成打印信息
     complete: function(info){
      console.log(info)
     },
    })

   },
   fail: function(err) {
    console.log(err)
   },
   complete: function(info) {
    console.log(info)
   },
  })
 },

 onReady:function(){
  // 頁面渲染完成
 },
 onShow:function(){
  // 頁面顯示
 },
 onHide:function(){
  // 頁面隱藏
 },
 onUnload:function(){
  // 頁面關(guān)閉
 }
})

 

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

相關(guān)文章

最新評論