[英]Geolocation error for ionic app is work on browser but not work on android mobile
i am developing a map based project in which app tries for geolocation of user, if GPS not enable it shows an error message. 我正在开发一个基于地图的项目,如果GPS未启用,则该应用会尝试对用户进行地理位置定位,并显示错误消息。 the code will work properly on browser.
该代码将在浏览器上正常工作。 but when i use this app on phone it will not working.
但是,当我在手机上使用此应用程序时,它将无法正常工作。
cede is here:-
navigator.geolocation.getCurrentPosition(function(pos) {
map.setCenter(new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude));
marker = new google.maps.Marker({
position: new google.maps.LatLng(pos.coords.latitude, pos.coords.longitude),
icon:'http://maps.google.com/mapfiles/ms/icons/green-dot.png',
draggable:true,
map: map,
title: "My Location"
});
console.log(marker.getPosition());
console.log(marker.getPosition().A);
console.log(marker.getPosition().F);
infoWindow.setContent('<div><strong>'+ "You are here!!" + '</strong><br>');
infoWindow.open(map, marker);
},
function onError(error){
$ionicPopup.alert({
title: 'Alert',
template: 'Please Turn on your GPS and come back'});
});
at last i have found solution of it...i have add {maximumAge:60000,timeout:3000,enableHighAccuracy:true} to my code 最后我找到了解决方案...我在我的代码中添加了{maximumAge:60000,timeout:3000,enableHighAccuracy:true}
function onError(error){
$ionicPopup.alert({
title: 'Alert',
template: 'Please Turn on your GPS and come back'});
}
{maximumAge:60000,timeout:3000,enableHighAccuracy:true});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.