【问题标题】:Google HTML 5 Geolocation 'use my location' only working in FirefoxGoogle HTML 5 Geolocation“使用我的位置”仅适用于 Firefox
【发布时间】:2016-07-10 12:07:55
【问题描述】:

我有一个按钮,用于检查您的位置,然后显示最近的位置。

我已经让它在 Firefox 中完美运行,之前它不在实时域上,而是在开发服务器上,我看到了一些支持它必须在 html 5 地理定位的实时域上的想法的资源在 Chrome 中工作。

现在我们已经转移到真实域,结果仍然相同,只有 Firefox 在运行,并且在 Chrome 中,我很确定 Safari 显示“无法检索位置”意味着出现错误。我已确保检查 Chrome 是否没有阻止该站点请求我的位置(没有弹出单击是/否的弹出窗口),尽管它肯定在我的设置中被激活。在不同 PC 上的结果相同。

有什么想法可以阻止这个吗?它位于实时域中。

这是我的代码:

function geoFindMe() {

var output = $('.location-use');

if (!navigator.geolocation){
   $(".location-use").html('Geolocation is not supported by your browser');
return;
}

 function success(position) {
 var latitude  = position.coords.latitude;
 var longitude = position.coords.longitude;

output.innerHTML = '<p>Latitude is ' + latitude + '° <br>Longitude is ' + longitude + '°</p>';

  //find nearest restaurant location from these lat n long
  NearestLoc( latitude, longitude );

};



 function error() {
   $(".location-use").html('Unable to retrieve your location');
 };

$(".location-use").html('Locating...');

  navigator.geolocation.getCurrentPosition(success, error);
 }

【问题讨论】:

标签: javascript html google-chrome firefox geolocation


【解决方案1】:

https://developers.google.com/web/updates/2016/04/geolocation-on-secure-contexts-only

这个答案在这里(感谢 user3186314),Chrome 需要 HTTPS

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-13
    • 1970-01-01
    • 1970-01-01
    • 2014-10-12
    • 1970-01-01
    • 2014-11-15
    • 1970-01-01
    • 2012-04-24
    相关资源
    最近更新 更多