其实,我的需求是很简单的,就是页面一打开获取当前的省份位置;
map(){
let _this = this;
var geolocation = new BMap.Geolocation(); //获取位置定位
var gc = new BMap.Geocoder(); //// 创建地址解析器实例
geolocation.getCurrentPosition(function (r) { //r返回经纬度还有省市信息
console.log(r.address);
if (this.getStatus() == BMAP_STATUS_SUCCESS) {
_this.province = r.address.province.replace(/省|市|自治区|壮族|维吾尔|回族/gi,'') ; //项目需求需要过滤一些特殊词
}
else {
_this.tip = "定位失败,请刷新页面重试!";
}
}, { enableHighAccuracy: true });
}