获取地理位置定位信息-app端
getLoad() {
let site = {}
let onSuccess = (position) => {
site.code = 0
site.position = [position.coords.longitude, position.coords.latitude]
let map = new BMap.Map("allmap");
let point = new BMap.Point(site.position[0],site.position[1]);
let gc = new BMap.Geocoder();
let that = this
gc.getLocation(point, function(rs) {
let addComp = rs.addressComponents;
let mapAddress = addComp.province+addComp.city + addComp.district
+ addComp.street + addComp.streetNumber;
alert(mapAddress)
});
}
let onError = (error) => {
site.code = error.code
site.position = error.message
}
navigator.geolocation.getCurrentPosition(onSuccess, onError, {
maximumAge: 3000,
timeout: 5000,
enableHighAccuracy: true
})
},