zoukankan      html  css  js  c++  java
  • 在微信小程序中将获取到的经纬度(经度纬度)转地址(地名)

    var QQMapWX = require('qqmap-wx-jssdk')
    var qqmapsdk = new QQMapWX({
        key: '填写你的key' // 必填
    })
        wx.getLocation({
          type: 'wgs84',
          success (res) {
              console.log('纬度', res.latitude, '经度', res.longitude)
              wx.setStorageSync('latitude', res.latitude)
              wx.setStorageSync('longitude', res.longitude)
          },
         //wx.getLocation  回调里面把上面获取到的经纬度给引入的qqmap-wx-jssdk就可以获取到对应的地点了
          complete () {
            // 坐标转换
            qqmapsdk.reverseGeocoder({
              // 位置坐标,默认获取当前位置,非必须参数
                location: {
                  latitude: wx.getStorageSync('latitude'),
                  longitude: wx.getStorageSync('longitude')
                },
                success: function (res) {
                  console.log(res.result.address_component.city)
                  wx.setStorageSync('address_component', res.result.address_component.city)
                },
              fail: function (error) {
                console.error('错误', error)
              }
            })
          }
        })

     微信公众平台 | 小程序 >   开发  在这里配置域名  https://apis.map.qq.com 

  • 相关阅读:
    Memcached安装
    linux 安装telnet
    varnish应用
    linux 安装apache
    varnishlog、Varnishstat详解
    varnish CLI管理
    varnish 子程序流程
    python3 cms识别类
    python3 fofa爬取类
    每日健康打卡
  • 原文地址:https://www.cnblogs.com/Model-Zachary/p/10318497.html
Copyright © 2011-2022 走看看