navigator.geolocation getCurrentPosition not updating in Chrome Mobile

前端 未结 3 2207
粉色の甜心
粉色の甜心 2020-12-15 01:07

I have created a site (can be accessed at http://dev.gkr33.com) which is designed for a smartphone and attempts to use the navigator.geolocation api and grab your position v

3条回答
  •  生来不讨喜
    2020-12-15 01:27

    I finally found a working version for firefox, chrome & default navigator in android (4.2 tested only):

    function getGeoLocation() {
            var options = null;
            if (navigator.geolocation) {
                if (browserChrome) //set this var looking for Chrome un user-agent header
                    options={enableHighAccuracy: false, maximumAge: 15000, timeout: 30000};
                else
                    options={maximumAge:Infinity, timeout:0};
                navigator.geolocation.getCurrentPosition(getGeoLocationCallback,
                        getGeoLocationErrorCallback,
                       options);
            }
        }
    

提交回复
热议问题