Geolocation getCurrentPosition function broken in Chrome 65

The reason your geolocate code is no longer working..

- Chris Pook, 21st March 2018

As of the Chrome 65 update rolled out in March 2018, a bug has been introduced to the geolocate functionality of the browser. This manifests itself in timeouts to all calls to navigator.geolocation.getCurrentPosition() and navigator.geolocation.watchPosition().

We came across this bug during development of our Magento Collect in Store application which relies on the API to allow users to find collection locations near to them.

As of today we haven't been able to find a work around to the bug. However we suggest that you handle the situation by ensuring a timeout is set so that the function calls don't disappear in to a black hole. By setting a 5 second timeout you can gracefully return a message to the user along the lines of "location services are not available in your browser currently".

if (navigator.geolocation) {
        function (position) {
            // on success this will be called.
        function (err) {
            // on error (including timeout) this function will be called.
            timeout: 5000
location icon

Visit us

Mainyard Studios
35 Bow Rd, London E3 2AD