0

以下を使用して、ハンドセットの場所を取得しています..

  <script src="http://maps.google.com/maps/api/js?sensor=true"></script>

  <script type="text/javascript" >
   $(document).ready(function () {

 // wire up button click
 $('#go').click(function () {
    // test for presence of geolocation
     if (navigator && navigator.geolocation) {
         // make the request for the user's position
         navigator.geolocation.getCurrentPosition(geo_success, geo_error);
     } 
 });
 });


 function geo_success(position) {
  printAddress(position.coords.latitude, position.coords.longitude);
  alert(position.coords.latitude + " " + position.coords.longitude)
 }


  // use Google Maps API to reverse geocode our location
   function printAddress(latitude, longitude) {
 // set up the Geocoder object
  var geocoder = new google.maps.Geocoder();

 // turn coordinates into an object
 var yourLocation = new google.maps.LatLng(latitude, longitude);


 // find out info about our location
 geocoder.geocode({ 'latLng': yourLocation }, function (results, status) {
     if (status == google.maps.GeocoderStatus.OK) {
         if (results[0]) {
             $('body').append('<p>Your Address:<br />' +
                 results[0].formatted_address + '</p>');
         } else {
             error('Google did not return any results.');
         }
     } else {
         error("Reverse Geocoding failed due to: " + status);
     }
 });

 }
 }

結果は携帯電話の GPS から得られることはありません。位置を追跡する許可を求めます。ローカルエリアのランダムな場所を返します。

どうしてこれなの?

4

3 に答える 3

1

簡単な答え、答えはありません。すべての電話はこれを異なる方法で扱います。GPSを強制する唯一の方法はネイティブアプリです

于 2013-05-03T22:21:56.277 に答える
0

それはデバイスによって異なります。多くのデバイスが実際に正しい位置を返すことがわかります。

GPSが初期化されると、衛星からの適切な修正が行われず、最後に認識された位置、ネットワークデータに基づく位置、または限られた衛星データに基づく位置が提供されることに気付く可能性があります。

一部のデバイスは、「粗い」場所のみを共有するように構成することもできます。これは、それほど具体的でも正確でもありません。

于 2012-11-24T09:22:51.840 に答える
0

ほとんどのスマートフォンには、高精度(細かい)測位用のGPSや低精度(粗い)測位用のセルタワーの位置情報など、複数の測位手段があります。成功関数で返された位置で、の精度の推定値を取得する必要がありますcoords.accuracy

位置クエリを実行するときに、次のように指定することで高精度の応答を要求できますenableHighAccuracy = true

 navigator.geolocation.getCurrentPosition(geo_success, geo_error,
       {enableHighAccuracy = true});

一部のデバイスでは高精度の測位にアクセスできないため、これが常に機能するとは限らないことに注意してください(いくつかの考慮事項については、GPS測位がバッテリーの使用に影響を与えることもあります)。

于 2012-11-24T09:24:58.433 に答える