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

Java Development

Posts: 285
Registered: ‎08-26-2011
My Device: 9900
My Carrier: Not Specified
Accepted Solution

Without using Google Maps I want to show distance between two places.

[ Edited ]

I want to get the distance between two places with latitudes and longitudes but I don't want to use google map url for getting Latitudes and longitude. Only with Blackberry api.


My Requirement is:


Take one places as constant place and another place is changes according to the GPS Location and then find the distance between them.


Ex: 1. Ahmedabad(Which is in Gujarath state, India) is constant place in your mobile when application loading.

2. when you go to some other place with your mobile then it gives the distance between them.


we don't want to use google maps to get latitude and longitude points for these places.


I have a method Coordinates to get distance between two latitude and longitude. But first I want the latitude and logitude for these places.

I hope you all understand.



Feel free to click LIKE button if the solution helps you;

Posts: 123
Registered: ‎07-08-2011
My Device: Torch 9800, Bold 9700
My Carrier: Bell, Rogers

Re: Without using Google Maps I want to show distance between two places.

If you have 2 points long/lat and is ok with straight surface distance then you can use this.


But if you want a more accurate road driving distance than you would have to use some webservice for this.



private double distance(double lat1, double lon1, double lat2, double lon2, char unit) {
  double theta = lon1 - lon2;
  double dist = Math.sin(deg2rad(lat1)) * Math.sin(deg2rad(lat2)) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.cos(deg2rad(theta));
  dist = Math.acos(dist);
  dist = rad2deg(dist);
  dist = dist * 60 * 1.1515;
  if (unit == "K") {
    dist = dist * 1.609344;
  } else if (unit == "N") {
  	dist = dist * 0.8684;
  return (dist);

Berobo Inc.
Police Scanner Radio / Alarm Clock lets you listen to Police scanners in your area!
Please click the Like button to thank the user that has helped you and
please mark post as solved when you have found the solution to your problem.
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Without using Google Maps I want to show distance between two places.

Sorry for late post - just  found this and wanted t update it in case someone else found it too. 


I recommend Coordinates distance() method for this.