2012-12-27 82 views
1

我已經創建了一個應用程序,該應用程序在iPad/iPhone上查找地理位置座標,但在某些Android設備上未能這樣做,即使設備是GPS功能。它適用於某些Android設備(例如三星Galaxy選項卡SCH-I800),並在某些其他選項(例如Samsung Galaxy選項卡GT-P5113)上失敗。爲什麼我的手機差距應用程序無法在某些Android設備上找到地理位置

任何想法可能是什麼原因的問題?

的示例代碼段:

<script type="text/javascript" 
src="http://maps.google.com/maps/api/js?sensor=true"></script> 
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=true"> </script> 
    <script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script> 

function onDeviceReady() 
{ 
navigator.geolocation.getCurrentPosition(onSuccess, onError); 
} 

var onSuccess = function(position) { 

      pos = new google.maps.LatLng(position.coords.latitude, 
             position.coords.longitude); 
      lat=position.coords.latitude; 
      lng=position.coords.longitude; 
      alert("lat: "+lat+" long "+lng); //i should get the lat/long here which i need to use further in my code 
     } 

對於其中應用無法正常運行它會ONERROR功能的設備。

function onError(error) { 

     alert("error code is: "+error.code);//it gives error code 3 when on such devices 


     } 

回答

1

您需要設置 「enableHighAccuracy」 選項設置爲使用GPS這些Android設備上觀看時:

navigator.geolocation.watchPosition(onSuccess, onError, { enableHighAccuracy: true }); 

看到這個答案也是:Phonegap Android and GPS satellite

+1

我已經嘗試使用「enableHighAccuracy」。它不適用於此也。我認爲這個屬性更關係到準確性,而我的問題是我沒有得到任何位置只在這些設備上。 –

0

您的應用程序沒有按」 t因爲此錯誤而工作:

PositionError.TIMEout

當設備無法在geolocationOptions的timeout屬性中指定的時間內檢索位置時返回。當與geolocation.watchPosition結合使用時,可能會在每超時毫秒時將此錯誤調用到geolocationError回調中。

+0

是的,它提供超時錯誤,但只在一些特定的設備上,另一方面工作。這很奇怪,因爲當我試圖尋找我在地圖上使用該設備的位置時,它顯示了我目前的位置,但是即使在其他設備顯示的位置。 –

+0

您需要這樣的代碼:pos = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);? –

0

設置 「enableHighAccuracy」 選項設置爲false,然後如果你的代碼錯誤2(ü可能得到有時),只是

轉到

菜單--->設置---->地點&安全

,然後檢查

使用無線網絡。

這解決了我的問題,並希望它解決了你的問題...... !!

0

如果我的項目和我的客戶堅持認爲他可以進入地圖,並且幾乎可以立即發現Hus地理位置,而在我的應用程序中它永久使用或無法工作,那麼我有一個問題。

解決方案是及時回到插件git倉庫,找到已刪除的java文件並使用該版本。

發生了什麼事情是插件維護人員剛剛使用了原生瀏覽器地理位置,本質上根本不使用插件,但在某些手機中,它只是沒有達到要求。另一種方法可以在你的應用中使用人行橫道。

我知道它不是一個「好」的解決方案,但它是獲得可接受性能所必需的。

相關問題