Javascript 位置数据me和x未在mac和ios上的chrome和safari中显示
我已经接管了一个名为foryrinfo.com的项目,当你访问其他页面时,它会计算出你与该地区其他场馆之间的距离 这适用于firefox和iphone 5上使用ios7的safari浏览器。但不是其他设备和浏览器 基本上,我是想找出我如何追踪它的断裂点。该站点使用Laravel 4构建。地理位置使用JS完成,并通过ajax传递到另一个页面 由于最初的开发人员不在,我不能要求他亲自尝试调试,但是laravel和ajax不是我的强项 如果有人知道我如何开始调试这个,我将不胜感激 更新: 该应用程序在Chrome中工作,但仅在匿名模式下工作。这一点我也摸不透 这是原始开发人员编写的JS代码,我添加了警报,这样我就可以遵循流程了Javascript 位置数据me和x未在mac和ios上的chrome和safari中显示,javascript,ajax,google-chrome,geolocation,laravel,Javascript,Ajax,Google Chrome,Geolocation,Laravel,我已经接管了一个名为foryrinfo.com的项目,当你访问其他页面时,它会计算出你与该地区其他场馆之间的距离 这适用于firefox和iphone 5上使用ios7的safari浏览器。但不是其他设备和浏览器 基本上,我是想找出我如何追踪它的断裂点。该站点使用Laravel 4构建。地理位置使用JS完成,并通过ajax传递到另一个页面 由于最初的开发人员不在,我不能要求他亲自尝试调试,但是laravel和ajax不是我的强项 如果有人知道我如何开始调试这个,我将不胜感激 更新: 该应用程序在
if (store.enabled) {
if (navigator.geolocation) {
var now = 0,
timestamp = 0,
difference = 0,
storedLocation;
if (store.get('location')) {
storedLocation = store.get('location');
timestamp = storedLocation.timestamp;
}
now = new Date().getTime();
difference = now - timestamp;
alert(now +'-'+timestamp);
if (difference > 1000) {
alert('diff > 1k');
navigator.geolocation.getCurrentPosition(function (position) {
if ( ! storedLocation) {
alert('NO STORED LOC.');
analytics.track('GeoLocation Updated');
store.set('location', position);
} else {
alert('now in the else statement');
difference = position.timestamp - timestamp;
if ((storedLocation.coords.latitude != position.coords.latitude) || (difference > 6000 || difference < 0)) {
alert('storedLocation != position.coords.latitude');
analytics.track('GeoLocation Updated');
store.set('location', position);
}
return;
}
$.ajax({
url: "/location",
type: 'POST',
data: {lat: position.coords.latitude, lon: position.coords.longitude}
}); // Do AJAX Query and update the server session with location
});
}else {
alert('bleeeerh');
}
}
}
if(store.enabled){
if(导航器.地理位置){
var现在=0,
时间戳=0,
差=0,
存储位置;
if(store.get('location')){
storedLocation=store.get('location');
timestamp=storedLocation.timestamp;
}
现在=新日期().getTime();
差异=现在-时间戳;
警报(现在为+'-'+时间戳);
如果(差值>1000){
警报('diff>1k');
navigator.geolocation.getCurrentPosition(函数(位置){
如果(!存储位置){
警报(“无存储LOC”);
analytics.track(“地理位置更新”);
store.set('位置');
}否则{
警报(“现在在else语句中”);
差异=位置。时间戳-时间戳;
if((存储位置.坐标.纬度!=位置.坐标.纬度)| |(差值>6000 | |差值<0)){
警报('storedLocation!=位置.坐标.纬度');
analytics.track(“地理位置更新”);
store.set('位置');
}
返回;
}
$.ajax({
url:“/location”,
键入:“POST”,
数据:{lat:position.coords.latitude,lon:position.coords.longitude}
});//执行AJAX查询并使用位置更新服务器会话
});
}否则{
警惕(“bleeerh”);
}
}
}
No没有php错误,从控制台上看也没有js错误。出于某种原因,它在隐姓埋名的情况下起作用。我发现从设备中删除缓存和cookies等修复了safari bug。