通过Android的GPS提供商在网站上进行地理定位?

通过Android的GPS提供商在网站上进行地理定位?,android,geolocation,gps,Android,Geolocation,Gps,我试图在一个常规的网站上获取移动设备的地理位置,而不是应用程序的网络视图或任何类似的本地内容。我得到了一个位置,但它非常不准确,准确度是3230或其他一些令人震惊的数字。我假设它是以米为单位的,无论如何它都不够精确。相比之下,笔记本电脑上的同一网页的准确度为30-40 我的第一个想法是,它使用的是网络提供商而不是GPS提供商,根据塔的位置和距离告诉我我在哪里。后来我做了一点研究,发现了EnableHighAccurance,并在我通过的选项中将其设置为真。包括这些之后,我仍然没有注意到任何区别

我试图在一个常规的网站上获取移动设备的地理位置,而不是应用程序的网络视图或任何类似的本地内容。我得到了一个位置,但它非常不准确,准确度是3230或其他一些令人震惊的数字。我假设它是以米为单位的,无论如何它都不够精确。相比之下,笔记本电脑上的同一网页的准确度为30-40

我的第一个想法是,它使用的是网络提供商而不是GPS提供商,根据塔的位置和距离告诉我我在哪里。后来我做了一点研究,发现了EnableHighAccurance,并在我通过的选项中将其设置为真。包括这些之后,我仍然没有注意到任何区别

以下是测试页面的HTML/javascript:

<html>
  <head>
    <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
    <script type="text/javascript">
      function OnLoad() {
        $("#Status").text("Init");
        if (navigator.geolocation) {
          $("#Status").text("Supports Geolocation");
          navigator.geolocation.getCurrentPosition(HandleLocation, LocationError, { enableHighAccuracy: true });
            $("#Status").text("Sent position request...");
          } else {
            $("#Status").text("Doesn't support geolocation");
        }
      }

      function HandleLocation(position) {
        $("#Status").text("Received response:");
        $("#Position").text("(" + position.coords.latitude + ", " + position.coords.longitude + ") accuracy: " + position.coords.accuracy);
        var loc = new Microsoft.Maps.Location(position.coords.latitude, position.coords.longitude);
        GetMap(loc);
      }

      function LocationError(error) {
        switch(error.code) {
          case error.PERMISSION_DENIED:
            alert("Location not provided");
            break;
          case error.POSITION_UNAVAILABLE:
            alert("Current location not available");
            break;
          case error.TIMEOUT:
            alert("Timeout");
            break;
          default:
            alert("unknown error");
            break;
        }
      }

      function GetMap(loc)  {
        var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials: "Aj59meaCR1e7rNgkfQy7j08Pd3mzfP1r04hGesGmLe2a3ZwZ3iGecwPX2SNPWq5a", center: loc, mapTypeId: Microsoft.Maps.MapTypeId.road, zoom: 15});
      }

    </script>
  </head>
  <body onload="javascript:OnLoad()">
    <div id="Status"></div>
    <div id="Position"></div><br/>
    <div id='mapDiv' style="position:relative; width:600px; height:400px;"></div>
  </body>
</html>

我正在运行Cynogen 6.1稳定、Android 2.2和GPS启用的MyTouch 3G上测试这一点。如果根是一个问题,我也有很多朋友和同事在他们的非根2.0+Android设备上尝试这个网页。每款手机对准确度都有不同的影响,但没有一款手机的准确度超过1000,我把这归因于不同的运营商。我还没有,但最终会用iPhone或其他位置感知手机进行测试。

Dang,你知道吗?