获取地理位置定位信息-app端

it2022-05-05  137

获取地理位置定位信息-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) { // alert(rs.sematic_description); 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 }) },

最新回复(0)