Question

I'm trying to use the HTML5 Geolocation on the following device:

  • HTC One X
  • Android 4.1.1
  • WebKit/534.30 (built-in browser WebKit version)

On the built-in browser and the latest version of the Chrome-app websites using the HTML5 Geolocation API won't be able to locate me. However, the Firefox-app locates me within seconds.

This is a problem, since multi-platform app-development platforms, e.g. PhoneGap, use WebViews (= built-in browser) as a container for the entire app. Furthermore, regular users won't try out different browsers if a web-app isn't able to do something it should be able to do.

My first thought was that it needed more time to locate me, so I set a timeout of 5 minutes (see bottom of post). But, it will just reach that timeout without finding my location. If I don't set a timeout, the callback-functions are never called (I waited for like an hour).

My second thought was that maybe somewhere on my phone or in my browser settings the location-requesting websites were blocked. This turned out not to be the case.

So my next thought is that maybe it's a programming issue in the sense that the browsers don't follow the W3C standards, so that their APIs might work differently. If so, how do I retrieve the location on this device / in these browsers?

Since even well-coded websites like Google aren't able to get my location on these browsers using that API, it might not be a programming issue. If it indeed isn't, which StackExchange website should I consult? (e.g., in case it's a device issue?)

The API I'm using (MDN):

navigator.geolocation.getCurrentPosition(success, error, options);

// Where success and error are callbacks and the options object may contain:
//   enableHighAccuracy - boolean, speaks for itself
//   timeout - maximum amount of milliseconds before one of the callbacks is called 
//   maximumAge - maximum age in milliseconds of cached location
Was it helpful?

Solution 2

It turned out to be a operating system issue, I guess. The latest update for that phone doesn't have the issue anymore.

I had tried the enableHighAccuracy: true option, but that didn't make any difference in my case. It did, though, make a lot of difference on other phones in terms of precision.

OTHER TIPS

Hi, I had a similar problem on the same device:

I set it as:

{enableHighAccuracy: true}.

Vladimir

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top