0
我已经使用下面的代码来检测角度应用中的当前位置。这与所有的桌面浏览器都能正常工作,但它不适用于移动设备,请在下面的代码中找到更多的理解。检测移动设备中当前的地理位置
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(onPositionUpdate,locNotFound,{frequency:5000,maximumAge: 0, timeout: 100, enableHighAccuracy:true});
} else {
// nothing
}
function locNotFound() {
console.log('location not found');
}
function onPositionUpdate(position) {
var lat = position.coords.latitude;
var lng = position.coords.longitude;
var url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=" + lat + "," + lng + "&sensor=true";
$http.get(url)
.then(function(result) {
console.log(result);
});
}
正如您所看到的,在移动设备中调用locNotFound()函数。它不应该这样做,因为GPS在移动设备上。
什么样的设备? –
我在Android(chrome,mozilla)和iOS(safari)中尝试过不适合我。 –