Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
New Developer
ttklf4
Posts: 43
Registered: ‎07-29-2008
My Device: Not Specified

Issues with JavaScript Location

The JavaScript Location only delivers coordinates from the GPS if the location was updated one time, i. e. if the coordinates change one time. This means that if a user does not change its location he cannot request his current position and this makes the JavaScript Location useless in most cases.

 

Is it possible to activate the GPS or the JavaScript Location without changing the position?

 

In the new BlackBerry Browser v4.6 on the simulator the locationupdate event used in  blackberry.location.onLocationUpdate(var method) is fired every two or three seconds and you can only stop it by closing the emulator. Is this a bug in your beta version?

 

Thank you very much. 

 

 

Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Issues with JavaScript Location

The onLocationUpdate method fires when the location updates, but you can also request an update or check the current location by accessing blackberry.location.longitude and blackberry.location.latitude.  The following knowledge base article explains this further.

 

 What Is - JavaScript methods to use location-based services
Article Number: DB-00450

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800878/852943/What_Is...

 

The onLocationUpdate method should only fire when the location has actually changed.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
ttklf4
Posts: 43
Registered: ‎07-29-2008
My Device: Not Specified

Re: Issues with JavaScript Location

Hello,

 

thank you very much for your reply.

 


MSohm wrote:

The following knowledge base article explains this further.

 

 What Is - JavaScript methods to use location-based services
Article Number: DB-00450

 


This knowledge base article is well known.

 


MSohm wrote:

 

The onLocationUpdate method should only fire when the location has actually changed.


 

This seems to be the issue which I have described in my question: If the page loads in a users browser the location does not change because the user does not change his position and latitude and longitude are 0. The same if I call blackberry.location.latitude and blackberry.location.longitude without refresh or onLocation Update.

Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Issues with JavaScript Location

Note that the GPS hardware on the BlackBerry is not active at all times.  When you first call refreshLocation the BlackBerry attempts to get a GPS fix and determine its location.  The time this takes can take a few seconds up to a few minutes depending on the BlackBerry model and GPS mode used.  Until the BlackBerry has a fix it could return 0 or the update from a previous fix.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
tonybunce
Posts: 13
Registered: ‎08-15-2008
My Device: Not Specified

Re: Issues with JavaScript Location

 

ttklf4 wrote:

In the new BlackBerry Browser v4.6 on the simulator the locationupdate event used in  blackberry.location.onLocationUpdate(var method) is fired every two or three seconds and you can only stop it by closing the emulator. Is this a bug in your beta version?

 


 

4.1 on the 8800 does the same thing.  I have found several issues with the GPS location javascript documentation. In my testing onLocationUpdate gets call even if the location doesn't change.  Even if it did it should be called at least once when the lat/long get changed from 0 to the correct value.  you can add  something like this in you onLocationUpdate to take care of it being called multiple times:

var gotUpdate = false; function locationCallback() { if (!(gotUpdate))

{

  //do stuff with blackberry.location.latitude

 

gotUpdate = true;

}

}

 

 

 
 More info from my testing can be found here: http://www.tonybunce.com/2008/05/08/BlackberryBrowserAmpGPS.aspx
Please use plain text.
New Developer
ttklf4
Posts: 43
Registered: ‎07-29-2008
My Device: Not Specified

Re: Issues with JavaScript Location

Hello Tony,

 

thank you very much for your reply.

 

I had already implemented your suggested solution to stop onLocationUpdate. The BlackBerry Browser 4.6 has a new method called removeLocationUpdate to remove the callback function.

 

But I am not sure if JavaScript location will always work on a real device. In all my emulators I only get coordinates when I change the location.

 

If you are interested in you can try my application with your BlackBerry under:

 

http://ttklf4.tempw8.internet1.de/m/New1/Search.aspx

 

 

 

 

 

Please use plain text.
New Developer
SASH
Posts: 1
Registered: ‎10-16-2008
My Device: Not Specified

Re: Issues with JavaScript Location

Hi tony,

 

I tried exactly the way you have tried but the OnLocationUpdate method is never called. But the refreshLocation method return true.

 

 

Please use plain text.
Administrator
MSohm
Posts: 14,528
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Issues with JavaScript Location

Have you enabled JavaScript location support on the BlackBerry?  To do so open the browser, select Options from the menu, click on General Properties and check off Enable JavaScript Location support.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
sanmanlan
Posts: 20
Registered: ‎03-05-2009
My Device: Not Specified

Re: Issues with JavaScript Location

hi tried to get the syntax but i am getting this error LocationTracker.java:64: expected UiApplication.getUiApplication().(new Runnable() ^ 1 error please can you tell me what seems to be the problem the thing is, i donot have much knowledge bout thread handling,

so troubling u with silly questions.

regards.

Please use plain text.
New Developer
spackler
Posts: 4
Registered: ‎03-25-2009
My Device: Not Specified

Re: Issues with JavaScript Location

Has anyone got Javascript API location to work on a Verizon Storm?
Please use plain text.