Blackberry.location API 无法正常工作 [英] Blackberry.location API not working correctly
问题描述
我正在尝试制作 Blackberry 小部件,但遇到了一些麻烦.
I am experimenting with making Blackberry widgets but having a little trouble.
我的第一个试验涉及显示一个按钮,当点击该按钮时,会调用一个 JavaScript 函数,该函数应该提醒手机的纬度和经度.
My first trial involves displaying a button which, when clicked, calls a JavaScript function that should alert the phones latitude and longitude.
函数看起来:
function whereAmI() {
var latitude = blackberry.location.latitude;
var longitude = blackberry.location.longitude;
alert("Lat: "+latitude+", Long: "+longitude);
}
但它只会提醒纬度:0,经度:0".我已经检查过了,我的 GPS 似乎工作正常.
But it only ever alerts "Lat: 0, Long: 0". I've checked and my GPS seems to be working ok.
我在 Curve 8900 上运行 OS 5.*.
I'm running OS 5.* on a Curve 8900.
任何帮助将不胜感激:)
Any help would be appreciated :)
推荐答案
我发现我没有正确签署文件 - 现在我签署了,一切正常.
I discovered that I wasn't signing my files properly - now that I have, everything works fine.
对于小包:
// 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");
}
这篇关于Blackberry.location API 无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!