navigator.geolocation.getCurrentPosition sometimes works sometimes doesn't

前端 未结 25 1673
伪装坚强ぢ
伪装坚强ぢ 2020-11-22 13:33

So I have a pretty simple bit of JS using the navigator.geolocation.getCurrentPosition jammy.

$(document).ready(function(){
  $(\"#business-locate, #people-l         


        
相关标签:
25条回答
  • 2020-11-22 14:34

    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);
            }
        }
    
    0 讨论(0)
提交回复
热议问题