this.getLocation()
getLocation(){
var options={
enableHighAccuracy:true,
maximumAge:1000
}
if(navigator.geolocation){
//浏览器支持geolocation
navigator.geolocation.getCurrentPosition(this.onSuccess,this.onError,options);
}else{
//浏览器不支持geolocation
}
},
onSuccess(pos){
console.log(“经度:”+pos.coords.longitude+“纬度:”+pos.coords.latitude)
},
onError(error){
switch(error.code){
case 1:
alert(“位置服务被拒绝”);
break;
case 2:
alert(“暂时获取不到位置信息”);
break;
case 3:
alert(“获取信息超时”);
break;
case 4:
alert(“未知错误”);
break;
}
},
04-20
1380

11-21
3241

03-04
2231
