navigator.geolocation.getcurrentposition不在safari中工作

问题描述:

这是我用于获取位置的代码。但不幸的是,它总是打印“失败回拨”。navigator.geolocation.getcurrentposition不在safari中工作

var location_timeout = setTimeout(function(){alert('failed');}, 10000); 
     navigator.geolocation.getCurrentPosition(function(position) { 
      findInStore.isGeoLocationPos = position; 
      clearTimeout(location_timeout); 
      alert('Succ call back') 
      findInStore.onDirectionLocation(event); 
     },function(){clearTimeout(location_timeout); 
     alert('failure call back');}); 

尝试

http://*.com/questions/7350033/geolocation-not-working-in-safari 
http://*.com/questions/3397585/navigator-geolocation-getcurrentposition-sometimes-works-sometimes-doesnt 

和几个。但没有任何帮助。 getCurrentPosition调用失败。有什么建议么?我不擅长这一点。

打开您的计算机上的Wifi,它将工作。 Safari使用wifi来对您的电脑进行地理定位:-)