Firefox 地理定位比 iPhone Safari 准确?
我刚刚在 Firefox 3.6 和 iPhone Safari (os 3.1.3) 上测试了 Geolocation,结果很有趣,firefox 比 safari 更准确。任何人都知道如何使 iPhone Safari 结果更加准确。
测试结果
- Windows Vista Firefox 3.6: ------------- 准确度: 150
- iPhone 3G (os 3.1.3) Safari: ---------- - 准确度:828
这是测试代码:
navigator.geolocation.getCurrentPosition(handler, {enableHighAccuracy: true});
function handler(location) {
var message = document.getElementById("message");
message.innerHTML = "<img src='http://maps.google.com/staticmap?sensor=true¢er=" + location.coords.latitude + "," + location.coords.longitude + "&size=300x300&maptype=street&zoom=16&key=ABQIAAAAZrVtlT2df2pkfI_RZB_6WBRWTAkRKJS7h1XjKaOTqACHuw1n0BT5cATkkKFnZNGHmrwUw9IilQK0Eg' />";
message.innerHTML+="<p>Longitude: " + location.coords.longitude + "</p>";
message.innerHTML+="<p>Latitude: " + location.coords.latitude + "</p>";
message.innerHTML += "<p>Accuracy: " + location.coords.accuracy + "</p>";
// call the function with my current lat/lon
getPlaceFromFlickr(location.coords.latitude, location.coords.longitude, 'output');
}
。 。
I just tested Geolocation on Firefox 3.6 and iPhone Safari (os 3.1.3), the result is interesting, firefox is more accurate than safari. any one got idea how to make iPhone Safari result more accurate.
Testing Resul
- Windows Vista Firefox 3.6: ------------- Accuracy: 150
- iPhone 3G (os 3.1.3) Safari: ----------- Accuracy: 828
this is the code for testing:
navigator.geolocation.getCurrentPosition(handler, {enableHighAccuracy: true});
function handler(location) {
var message = document.getElementById("message");
message.innerHTML = "<img src='http://maps.google.com/staticmap?sensor=true¢er=" + location.coords.latitude + "," + location.coords.longitude + "&size=300x300&maptype=street&zoom=16&key=ABQIAAAAZrVtlT2df2pkfI_RZB_6WBRWTAkRKJS7h1XjKaOTqACHuw1n0BT5cATkkKFnZNGHmrwUw9IilQK0Eg' />";
message.innerHTML+="<p>Longitude: " + location.coords.longitude + "</p>";
message.innerHTML+="<p>Latitude: " + location.coords.latitude + "</p>";
message.innerHTML += "<p>Accuracy: " + location.coords.accuracy + "</p>";
// call the function with my current lat/lon
getPlaceFromFlickr(location.coords.latitude, location.coords.longitude, 'output');
}
.
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Firefox 使用 Google 的位置数据库,而 Safari 使用 Skyhook,因此您确实无能为力
Firefox uses Googles Database of locations while Safari Uses Skyhook, so there really isn't anything you can do
尝试使用 navigator.geolocation.watchPosition 来跟踪当前位置 - 也许通过多次更新,准确性会提高。请参阅 Safari 网页内容指南 - 获取地理位置
Try using navigator.geolocation.watchPosition to track the current location -- maybe the accuracy will improve with multiple updates. See Safari Web Content Guide - Getting Geographic Locations