【发布时间】: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);
}
【问题讨论】:
-
查看此帖子Geolocation API not working in Chrome 以获得可能的解决方案。
-
谢谢,看来 HTTPS 是问题。
标签: javascript html google-chrome firefox geolocation