引入第三方SDK
import amap from '../../libs/amap-wx.js';
定义、使用SDK
// 获取位置
amapPlugin: null,
// 高德开放平台上申请的key
map_key: '高德开放平台上申请的key',
// 使用高德SDK
this.amapPlugin = new amap.AMapWX({
key: this.map_key
});
方法
get_location() {
uni.showLoading({
title: '获取信息中'
});
this.amapPlugin.getRegeo({
success: (data) => {
if (data) {
this.Location_status = 1
}
var address_name = data[0].name
this.addr = address_name.substring(0, 2)
uni.hideLoading();
this.location_show = false
uni.showToast({
title: '您当前位置为' + this.addr,
icon: 'none',
position: 'bottom'
})
}
});
},
网友评论