获取经纬度
2019-11-12 本文已影响0人
Rose_yang
// 异步
created () {
let lng, lat;
if (navigator.geolocation && navigator.geolocation.getCurrentPosition) {
console.log('navigator 1', navigator);
navigator.geolocation.getCurrentPosition((position) => {
lng = position.coords.longitude;
lat = position.coords.latitude;
console.log('geo getCurrentPosition', lng, lat);
this.doGetTypeList(lng, lat);
}, (error) => {
console.log(error, '===error');
this.doGetTypeList(lng, lat);
});
} else {
this.doGetTypeList(lng, lat);
}
console.log('navigator', navigator);
console.log('geo', lng, lat);
},