Athanasios Emmanouilidis
Athanasios Emmanouilidis

Reputation: 2144

Geolocation not working in Chrome for Android and Firefox for Android

I have the following script that gets your geolocation and redirects you to Google Maps:

(function(){
navigator.geolocation.getCurrentPosition(function(position){location.href = 'http://www.google.gr/maps/place/' + position.coords.latitude + ',' + position.coords.longitude;});
}());

The redirection works OK in Chrome for Windows and Firefox for Windows but doesn't work for Chrome for Android and Firefox for Android.

Why is this?

Thank you in advance

Upvotes: 0

Views: 2505

Answers (1)

sp3
sp3

Reputation: 74

Because as you can see here : https://developer.mozilla.org/en-US/docs/Web/API/Navigator/geolocation

the geolocation API is not supported on all browsers and especially not on mobile browsers as of today. I don't mean that it doesn't work but that it doesn't always work in the correct way: people would have to allow your webapp to access their position & to do it in a standard way.

Also, window.location seems to be better than location.href as stated in another answer.

Upvotes: 2

Related Questions