
const QQMapWX = require("./qqmap-wx-jssdk.min.js")
module.exports = {
  getLocation: function(cb){
    wx.getLocation({
      type: 'wgs84',
      success: function (res) {
          let location = {
            latitude: res.latitude,
            longitude: res.longitude
          };
          cb&&cb( location )
        },
      fail: function( res ){
        cb && cb( {latitude:39.90 , longitude: 116.47})
      }
      })
    },
    
    getAddress: function(location,  cb ){
      qqmapsdk = new QQMapWX({
        key: 'YESBZ-R54RO-R34W7-SOMH4-RTMFE-VOBRK'
      });
      qqmapsdk.reverseGeocoder({
        location:location,
        success: function (result) {
          location.city = result.result.address_component.city;
          location.address = result.result.address;
          cb&&cb( location );
        }
      })
    }

  }