2010-05-20 49 views
0

我正在嘗試製作黑莓小部件,但遇到了一些麻煩。Blackberry.location API無法正常工作

我的第一個試驗涉及顯示一個按鈕,當點擊該按鈕時,該按鈕會調用一個JavaScript函數來提醒電話的緯度和經度。

函數看起來:

function whereAmI() { 
var latitude = blackberry.location.latitude; 
var longitude = blackberry.location.longitude; 
alert("Lat: "+latitude+", Long: "+longitude); 
} 

但它永遠只能提醒 「緯度:0,長:0」。我檢查過了,我的GPS似乎工作正常。

我*在8900曲線

任何幫助運行OS 5,將不勝感激:)

回答

1

我發現我沒有正確簽署我的文件 - 現在我有,一切正常。

對於卡班:

 // called when location object changes 
    function locationCB() 
    { 
    alert("Latitude " + blackberry.location.latitude); 
    alert("Longitude " + blackberry.location.longitude); 
    return true; 
} 
// test to see if the blackberry location API is supported 
if(window.blackberry && blackberry.location.GPSSupported) 
{ 
     document.write("GPS Supported"); 

     // Set our call back function 
     blackberry.location.onLocationUpdate("locationCB()"); 

     // set to Autonomous mode 
     blackberry.location.setAidMode(2); 

     //refresh the location 
     blackberry.location.refreshLocation(); 
} 
else 
{ 
    document.write("This Device doesn't support the Blackberry Location API"); 
} 
+0

不幸的是,我希望你已經提供了更多'正確簽署我的文件'的含義,所以這可以幫助其他人... – Petrogad 2010-07-08 18:56:04

+0

好點。當您向RIM註冊成爲應用程序或小部件的開發人員時,您會得到一個代碼簽名密鑰,該密鑰會使用唯一代碼標記您的應用程序,以便在發生惡意使用時可以跟蹤開發人員。有很多簽名文件的方法,但我沒有正確地做。如果其他人有興趣,我可以提供具體細節。 – user97410 2010-08-04 10:54:02

+0

如果您有任何鏈接,這將有助於未來的其他人! 感謝您的迴應:) – Petrogad 2010-08-06 21:05:19

0

請問你的部件必須使用GPS的權限?轉到選項 - >應用程序,選擇您的應用程序,然後選擇「編輯權限」。確保「位置數據」(在連接中)設置爲允許。

+0

嗨,馬克。感謝您的建議。我看了一下,應用程序肯定可以訪問位置數據,幾乎所有的東西,但它仍然返回0. – user97410 2010-05-21 15:47:33