• 微信小程序——获取具体地理位置信息


    通过微信自己的接口API,用户授权后获取到经纬度,通过经纬度调用地图接口返回地理位置信息。

    简单、明了!!!(网上自己查询的文档进行编程,转载请注明出处)

    代码如下:

    qqMapApi: 'http://apis.map.qq.com/ws/geocoder/v1/', //地图接口链接
     
    //获取经纬度
    getPosition() {
    let that = this;
    wx.getLocation({
    type: 'wgs84',
    success: function(res) {
    var latitude = res.latitude;
    var longitude = res.longitude;
    // wx.setStorageSync('latitude', latitude) //纬度
    // wx.setStorageSync('longitude', longitude) //经度
    var qqMapApi = that.qqMapApi + "?location=" + latitude + ',' +
    longitude + "&key=" + 'XVLBZ-BSU66-ULJSQ-MFGXD-TM7GZ-55F2M' + "&get_poi=1";
    wx.request({
    url: qqMapApi,
    data: {},
    method: 'GET',
    success: (res) => {
    console.log(res)
    if (res.statusCode == 200 && res.data.status == 0) {
    that.country = res.data.result.address_component.nation;
    that.province = res.data.result.address_component.province;
    that.city = res.data.result.address_component.city;
    that.county = res.data.result.address_component.district;
    that.street = res.data.result.address_component.street;
    }
    }
    })
    },
    fail() {
    that.fn_fail();
    }
    })

    },
  • 相关阅读:
    Linux Shell常用技巧(二)
    Linux Shell常用技巧(一)
    Linux Shell常用命令总结
    不大于N的所有素数
    include指令
    PotPlayer 进度条显示缩略图
    PotPlayer 禁止更新
    a标签添加点击事件
    配置JDK环境变量
    电路交换与分组交换的差别
  • 原文地址:https://www.cnblogs.com/zhangjiabin/p/8276400.html
Copyright © 2020-2023  润新知