2012-02-09 2 views
0

私はphonegapプラットフォーム上のアンドロイドエミュレーターでgeolocationを使用して座標を取得しようとします。しかし、それは動作していないようです。コードが正しくなければならない、私はマニフェストの許可を追加し、highacuracyタグを使用します、どうすればこの問題に対処できますか?ありがとう!アンドロイドphonegapジオロケーションエミュレーター

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Device Properties Example</title> 

    <script type="text/javascript" charset="utf-8" src="phonegap.js"></script> 
    <script type="text/javascript" charset="utf-8"> 

    // Wait for PhoneGap to load 
    // 
    document.addEventListener("deviceready", onDeviceReady, false); 

    // PhoneGap is ready 
    // 
    function onDeviceReady() { 
     navigator.geolocation.getCurrentPosition(onSuccess, onError,{ enableHighAccuracy: true }); 
    } 

    // onSuccess Geolocation 
    // 
    function onSuccess(position) { 
     var element = document.getElementById('geolocation'); 
     element.innerHTML = 'Latitude: '   + position.coords.latitude    + '<br />' + 
          'Longitude: '   + position.coords.longitude    + '<br />' + 
          'Altitude: '   + position.coords.altitude    + '<br />' + 
          'Accuracy: '   + position.coords.accuracy    + '<br />' + 
          'Altitude Accuracy: ' + position.coords.altitudeAccuracy  + '<br />' + 
          'Heading: '   + position.coords.heading    + '<br />' + 
          'Speed: '    + position.coords.speed     + '<br />' + 
          'Timestamp: '   + new Date(position.timestamp)   + '<br />'; 
    } 

    // onError Callback receives a PositionError object 
    // 
    function onError(error) { 
     alert('code: ' + error.code + '\n' + 
       'message: ' + error.message + '\n'); 
    } 

    </script> 
    </head> 
    <body> 
    <p id="geolocation">Finding geolocation...</p> 
    </body> 
</html> 
+0

エミュレータでジオロケーションを次のように設定し、eclipseでDDMSに移動し、エミュレータのlantitude、longitudeを選択して、ここに画像の説明を入力します – Arivu

答えて

1

シミュレータの位置を設定しましたか?

例えば:

$ telnet localhost 5554 
$ geo fix -4.2 55.85 
関連する問題