亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

微信小程序 location API實(shí)例詳解

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

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

主要屬性:

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

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

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

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

wxml

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

js

Page({
 data:{
  text:"Page location"
 },
 onLoad:function(options){
  // 頁(yè)面初始化 options為頁(yè)面跳轉(zhuǎn)所帶來(lái)的參數(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,
     //縮放級(jí)別默認(rèn)28
     scale: 28,
     //位置名
     name: '測(cè)試地址',
     //詳細(xì)地址
     address: '火星路24號(hào)',
     //成功打印信息
     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(){
  // 頁(yè)面渲染完成
 },
 onShow:function(){
  // 頁(yè)面顯示
 },
 onHide:function(){
  // 頁(yè)面隱藏
 },
 onUnload:function(){
  // 頁(yè)面關(guān)閉
 }
})

 

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

相關(guān)文章

最新評(píng)論