I am trying to use the HTML5 geolocation API; but I have problems to get it working with Firefox Chrome and Chromium:
init(); function init() {; // Get the current location getPosition(); } function getPosition() { navigator.geolocation.getCurrentPosition(success, fail,{ enableHighAccuracy:true, timeout:10000, maximumAge:Infinity }); } function success(position) { alert("Your latitude: " + position.coords.latitude + "longitude: " + position.coords.longitude); } function fail(e) { alert("Your position cannot be found"+e.code+" => "+e.message); }
IE9 and Safari work flawlessly; but:
- Firefox (v13 and V14) has error code 3 (timeout)
- Chrome and Chromium (v20 and v21) have error code 2 with the message "Network location provider" on the page https://maps.googleapis.com/maps/api/browserlocation/json?browser=googlechrome&sensor=true ': The answer was deformed .
I have a new installation of Chrome (installed today on Windows XP, no extensions), and I enabled geolocation in the browser.
You can try: http://jsfiddle.net/mhj82/38/
Is there a solution for it to work in all browsers that support geolocation?
source share