BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 12-04-2007, 06:04 PM   #21 (permalink)
New Member
 
Join Date: Dec 2007
Model: 8703e
PIN: N/A
Carrier: Sprint
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please Login to Remove!

Quote:
Originally Posted by camisa View Post
I too have a crippled Blackberry 7130e on Verizon Wireless.

Code:
<html>
<body>
<script language="Javascript">
<!--
if(blackberry.location.GPSSupported) {
blackberry.location.setAidMode(1);
blackberry.location.refreshLocation();
blackberry.location.onLocationUpdate(window.alert("Your new
position is " + blackberry.location.latitude +
" degrees latitude and " +
blackberry.location.longitude +
" degrees longitude."));
}
//-->
</script>
</body>
</html>
From a JavaScript perspective, your code is almost right, but there is a subtle error. This line is what is wrong:

blackberry.location.onLocationUpdate(window.alert( "Your new
position is " + blackberry.location.latitude +
" degrees latitude and " +
blackberry.location.longitude +
" degrees longitude."));

Passing a callback to another function should be in the form of function name only and not include the parenthesis. Parenthesis tell the function to execute immediately, which may be one of the reasons you're receiving the 0's.

You have to pass in a function, not execute the function.

Code:
function getLocation() {
    window.alert("Your new position is " + blackberry.location.latitude + " degrees latitude and " + blackberry.location.longitude + " degrees longitude.");
}
blackberry.location.onLocationUpdate(getLocation);
// you were doing: blackberry.location.onLocationUpdate(getLocation());
// which sends null to onLocationUpdate since getLocation doesn't return anything
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

16mm LED Blue Angel eye Metal Push Button Momentary Lighted Switch
$6.45
16mm LED Blue Angel eye Metal Push Button Momentary Lighted Switch picturePush Button Z Series Microswitch SPDT 15A 250VAC
$3.9
Push Button Z Series Microswitch SPDT 15A 250VAC pictureHUBBELL WIRING DEVICE-KELLEMS Manual Motor Switch,60A,600VAC,2P, HBL7862D
$141.5
HUBBELL WIRING DEVICE-KELLEMS Manual Motor Switch,60A,600VAC,2P, HBL7862D pictureOPTEK OPB857 OPTICAL SWITCH *NEW NO BOX*
$12.0
OPTEK OPB857 OPTICAL SWITCH *NEW NO BOX* pictureMILLER 43E REPLICA BRAKE LIGHT STOP SWITCH. NEW STOCK
$13.1
MILLER 43E REPLICA BRAKE LIGHT STOP SWITCH. NEW STOCK picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.