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("当前浏览器无法获取位置");
};
iOS之获取经纬度并通过反向地理编码获取详细地址
_locationManager = [[CLLocationManager alloc] init]; //期望的经度 _locationManager.desiredAccuracy = kCLL ...
html5获取经纬度,百度api获取街区名,并使用JS保存进cookie
引用js