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

微信小程序如何獲取地址

 更新時(shí)間:2019年12月24日 11:46:33   作者:曳貓、  
這篇文章主要介紹了微信小程序獲取地址的具體方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了微信小程序獲取地址的具體代碼,供大家參考,具體內(nèi)容如下

wxml

<map id="map" longitude="{{data.longitude}}" latitude="{{data.latitude}}" scale="14" markers="{{markers}}" polyline="{{polyline}}" show-location style="width: 100%; height: 500px;"></map>
<text>
 {{data.longitude}}
 {{data.latitude}}
 {{address}}
</text>
<!-- longitude 中心經(jīng)度 -->
<!-- latitude 中心緯度 -->
<!-- scale 縮放級(jí)別,取值范圍為3-20 -->
<!-- markers 標(biāo)記點(diǎn) -->

js

var QQMapWX = require('../js/qqmap-wx-jssdk.js');
var qqmapsdk;
Page({
 data:{
  data:"",
  str:"",
  address:""
 },
 onLoad: function () {
  let _this = this;
  // 實(shí)例化API核心類
  qqmapsdk = new QQMapWX({
   key: 'key'
  });
  // Promise 獲取地址
  let gets = new Promise((resolve, reject) => {
   wx.getLocation({
    type: 'wgs84',
    success:resolve
   })
  }).then(function(res){
   console.log(res)
   _this.setData({
    data:res
   })
  })

  // 正常方式獲取地址
  wx.getLocation({
   type: 'wgs84',
   success:function(res){
    _this.setData({
     str: _this.res
    })
    console.log(res)
    var demo = new QQMapWX({
     key: 'key'
    });
    // 解析地址
    demo.reverseGeocoder({//地址解析
     location: {
      latitude: res.latitude,
      longitude: res.longitude
     },
     success: function (res) {//轉(zhuǎn)為具體地址
      console.log(res);
      //獲得地址
      _this.setData({
       address: res.result.address
      })
     },
     fail: function (res) {
      console.log(res);
     }
    });
   }
  })
 },

為大家推薦現(xiàn)在關(guān)注度比較高的微信小程序教程一篇:《微信小程序開發(fā)教程》小編為大家精心整理的,希望喜歡。

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

相關(guān)文章

最新評(píng)論

东台市| 南京市| 扎囊县| 和平县| 新龙县| 麟游县| 平顶山市| 墨竹工卡县| 斗六市| 吉安县| 广元市| 思南县| 万盛区| 康乐县| 略阳县| 双柏县| 洛隆县| 同德县| 三都| 剑川县| 北流市| 兴化市| 密山市| 临沭县| 浙江省| 泾源县| 合江县| 龙岩市| 额尔古纳市| 顺昌县| 镇原县| 舞阳县| 漠河县| 仁怀市| 阿尔山市| 克东县| 石渠县| 安国市| 开江县| 察哈| 文成县|