Hi there. I’m using ngCordova
Geolocation plugin in my ionic1 app. It gives me latitude and longitude only when I’m connected to wifi or mobile data. How can I do this work offline?
The error message for offline mode:
Network location provider at 'https://www.googleapis.com/' : No response received
NOTE: I searched and some one has said that I must use this option:
enableHighAccuracy: true
But no diffrenece.
EDIT: I found out it works somehow in real device. But not always. It’s searching for gps but just sometimes it can find.
1 Like
I did a small research and actually this questions has been asked many times even on stackoverflow but never get clear answer. There are many suggestions that really don’t work. I’m curious why even here there isn’t an answer? The problem is clear - cordova geolocation plugin works fine when GPS and WiFi (on real device) are together turned on at the same time. When the WiFi is turned off and GPS stays on, geolocation is not able to get lat and long. Even more, it doesn’t throw error for timeout.
When GPS is turned off and WiFi stays on it throws timeout (like it is expected) error but could not get the location. I tried to change timeout value - it didn’t help. Here is the code:
$cordovaGeolocation.getCurrentPosition({timeout: 30000, enableHighAccuracy : true}).then(
function (position) {
$scope.lat = position.coords.latitude;
$scope.lng = position.coords.longitude;
},
function (error) {
console.log(error.message);
});
Any suggestions?
See here for the reason: http://stackoverflow.com/a/38552942/4055329
Actually geoLocation
doesn’t work indoor. It doesn’t relate to cordova!
But in some smart phones it works even indoors.
Actually, I tried it indoor and outdoor - no difference. Doesn’t work.What I also noticed is that when I start the app, the icon for location (right upper corner near the clock) appears for a second and immediately disappears. For example, when I use Waze or google maps this icon appears and stays there till I lose GPS signal or close the app. Something is not right and I couldn’t figure it out.
the icon for location (right upper corner near the clock) appears for a second and immediately disappears
Yes, it’s the same for me. I think it’s relates to the phone.