标签:
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
function success(pos) {
alert(pos.coords.longitude + " ," + pos.coords.latitude );
},
function fail(error) {
var message = "";
switch (error.code) {
case error.TIMEOUT:
message = "连接超时,请重试";
break;
case error.PERMISSION_DENIED:
message = "您拒绝了使用位置服务,查询已取消";
break;
case error.POSITION_UNAVAILABLE:
message = "获取位置信息失败";
break;
}
alert( message)
},
{
timeout: 60000
}
);
}
else {
alert("当前浏览器无法获取位置");
};
标签:
原文地址:http://www.cnblogs.com/catzhou/p/4351779.html