JavaScript Geolocation failing in all Android browsers - working in iOS and PC -


here basic code:

if (navigator.geolocation) {       // point test `alert()`          navigator.geolocation.getcurrentposition(       // not ot point in android browser       function(position) {         var latitude = position.coords.latitude;         var longitude = position.coords.longitude;       }, showerror, {         enablehighaccuracy: true,         timeout : 5000,         maximumage: 0        }        );     } else {         return alert('no geolocation support.');     } }; 

it works great in ios (safari , chrome); , pc browsers i've tried.

on android, i've tried stock htc browser, chrome , dolphin. satellites searching then, stops. don't recall asking permission use geolocation (could have overlooked part)

update: work on nexus 10 chrome browser. not htc 1 x.

update 2 - appears happening on 1 android device, at&t htc 1 x. other android devices, pc browsers , ios work fine. on 1 x error code: timeout. also, gps works fine on device otherwise.

your code absolutely correct. i have tested in android 2.3 + latest version in different devices including htc, samsung, asus tablets , samsung tablets. in tablets, working fine. check if device has settings of share location false in device. when page script requesting location browser ask user permission in android device browser. may have clicked never share location. please check clearing browser settings in device. guarantee there no geolocation api problem in android 2.3+ without messing security settings.

and if still problem persists , want add @ least polyfill check https://github.com/modernizr/modernizr/wiki/html5-cross-browser-polyfills , have luck. calculate location based on ip usig geoip database.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -