Panda learn ape - Tencent micro letter calling applet Maps API

1, to Tencent https://lbs.qq.com/ , sign up for a key value

2, set in a small development program - set up the domain name server request legitimate domain name, add https://apis.map.qq.com

3, implementation scripts, obtain the coordinates of the location by wx.getLocation, using the inverse map Tencent resolve obtain the address name

// 引入SDK核心类
var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
var qqmapsdk;
Page({

  onLoad: function () {
    // 实例化API核心类
    qqmapsdk = new QQMapWX({
      key: '4BFBZ-JPWE4-OJDU7-XWEJ7-QWEDV-HSRES'
    });
  },
  onShow: function () {
    // 调用接口
    wx.getLocation({
      type: 'wgs84',
      success: function (res) {
        console.log(res);
        qqmapsdk.reverseGeocoder({
             location: {
               latitude: res.latitude,
               longitude: res.longitude
             },
             success: function (result) {
               console.log(result);
               console.log(result.result.address);
              
             }
           })

      }
    })
 
  }
  })
Published 165 original articles · won praise 34 · Views 350,000 +

Guess you like

Origin blog.csdn.net/liuhongwei_study/article/details/88940880