在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML5  HTML/ 微信小程序使用騰訊地圖api里面的坐標(biāo)怎么動(dòng)態(tài)的添加

微信小程序使用騰訊地圖api里面的坐標(biāo)怎么動(dòng)態(tài)的添加

onLoad: function () {

var _this = this;
wx.getLocation({
  type: 'wgs84',
  success: function (res) {
    var latitude = res.latitude
    var longitude = res.longitude
    _this.setData({ latitude1: latitude })
    _this.setData({ longitude1: longitude })
  }
});//獲取坐標(biāo)
demo.reverseGeocoder({
  location: {
    latitude: 39.984060,//就是這個(gè)地方,填入_this.data.latitude1不行
    longitude: 116.307520//直接寫(xiě)坐標(biāo)可以,但是填入_this.data.latitude1不報(bào)錯(cuò),也沒(méi)用問(wèn)題
  },
  success: function (res) {
    var name = res.result.address;
    _this.setData({motto:name});
  }
})//坐標(biāo)轉(zhuǎn)換為地址
回答
編輯回答
逗婦惱

getLocation 是個(gè)異步請(qǐng)求,應(yīng)該這樣寫(xiě)

wx.getLocation({
  type: 'wgs84',
  success: function (res) {
    // 寫(xiě)在 getLocation 的 success 里面
    demo.reverseGeocoder({
      location: {
        latitude: res.latitude,
        longitude: res.longitude
      }
    })
  }
});

希望對(duì)你有幫助

2017年5月13日 21:01