我正在从事基于位置的服务。我找不到任何与我的以下问题相关的明确答案,所以我问-
如何在我们自己的服务器上启用HTML5地理定位?或者有没有提供默认定位服务(如DNS)的中央地理位置数据库?
我在我的笔记本电脑上看到了谷歌地图(http://html5demos.com/geo)的地理定位精度(显然是免费的),这让我大吃一惊,它的范围在20米左右。技术是什么?如何在我们自己的系统中实现它?
当我用来搜索我的IP位置时,它会在地图上显示ISP办公室,距离大约15公里,而不是最近的情况,它显示了几乎准确的位置。可能的原因是什么?会不会是因为我使用的android手机使用的是同一个Wireles路由器,它会从那里获取位置?或者在HTML5中,他们开始定位特定的IP地址(这似乎有点不太可能)。
发布于 2010-11-02 00:44:41
你可以在优秀的Dive Into HTML 5中找到很多关于它的工作原理以及如何在你自己的网站上使用它的信息。本书推荐使用Modernizr,下面提供了一个简单的示例:
function get_location() {
if (Modernizr.geolocation) {
navigator.geolocation.getCurrentPosition(show_map);
} else {
// no native support; maybe try Gears?
}
}它在您的笔记本电脑上工作的主要方式是使用本地无线接入点的已知位置。这在不同的浏览器上有一点不同--火狐有a good explanation here。他们使用的是positioning services from Google,这是由谷歌街景车绘制的地图创建的。
发布于 2011-11-06 00:57:00
function GetGeolocation() {
navigator.geolocation.getCurrentPosition(GetCoords, GetError);
}现在检查GetCords函数
function GetCoords(position){
alert('latitude: '+ position.coords.latitude);
alert('longitude: '+ position.coords.longitude);
alert('accuracy: '+ position.coords.accuracy);
FindmeOnMap(position.coords.latitude, position.coords.longitude);
}发布于 2010-11-02 00:41:03
// Check for geolocation support
if (navigator.geolocation) {
// Use method getCurrentPosition to get coordinates
navigator.geolocation.getCurrentPosition(function (position) {
// Access them accordingly
alert(position.coords.latitude + ", " + position.coords.longitude);
});
}从…
http://robertnyman.com/2010/03/15/geolocation-in-web-browsers-to-find-location-google-maps-examples/
https://stackoverflow.com/questions/4070955
复制相似问题