标签:tps eve ref func lan 位置 onload fun success
关于微信小程序连接腾讯地图的介绍直接上代码
var global = getApp();
var o = global.globalData.siteInfo.siteUrl;
var i = require("../../common/common.js");
var QQMapWX = require(‘../../utils/qqmap-wx-jssdk.min‘);
var qqmapsdk;
onLoad: function (k) {
// 实例化API核心类
qqmapsdk = new QQMapWX({
key: ‘P7DBZ-V7MC4-OQBUH-X36F6-35YKH-BLBUQ‘
});
},onShow: function () {
// 调用接口
var that = this;
wx.getLocation({
type: ‘gcj02‘,
altitude: ‘true‘,
success: function (res) {
console.log(res)
//2、根据坐标获取当前位置名称,显示在顶部:腾讯地图逆地址解析
qqmapsdk.reverseGeocoder({
location: {
latitude: res.latitude,
longitude: res.longitude
}, //坐标
get_poi: 0, //是否获取坐标对应附近列表
poi_options: ‘policy=2;radius=3000;page_size=10;page_index=1‘, //poi 参数
success: function (res) {
var address = res.result.address_component;
console.log(res.result.address_component, "???????????")
that.setData({
province:address.province,
city:address.city,
});
if(that.data.province != null && that.data.city != null) {
wx.request({
url: o + "API/IndexMini/get_local",
data: {
applet_id: global.globalData.uniacid,
city: address.city[0] + address.city[1]
},
success: function (e) {
console.log(e.data.data, "11111111111");
that.setData(
{
your_city: e.data.data
}
)
}
})
}
}
})
}
});
},
标签:tps eve ref func lan 位置 onload fun success
原文地址:https://blog.51cto.com/14263015/2418500