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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

BlackBerry® World™ Development

Reply
New Developer
vishalkheterpal
Posts: 123
Registered: ‎01-11-2011

Problem with latitude and longitude

Hi all

         I am developing an application on blackberry.In my app i got the value of Latitude and Longitude from the server.Now i have to show this location on the Map.

my code is following:

 

 

        MapView mapView = new MapView();
        mapView.setLatitude(Integer.parseInt(latitude));
        mapView.setLongitude(Integer.parseInt(longitude));
        mapView.setZoom(10);
        MapsArguments mapsArgs = new MapsArguments(mapView);
        Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, mapsArgs);

the problem is I have the value of latitude and longitude as double data type from the server

but the method takes as int b'coz of this it don't show the location on map.

how i can set the value of latitude and longitude as double.

Please use plain text.
Developer
Dekerta
Posts: 80
Registered: ‎11-25-2010
My Carrier: Rogers

Re: Problem with latitude and longitude

I'm guessing the variables 'latitude' and 'longitude' are strings pulled from the server, in the form of "00.00000"

 

Also, note that when you set the latitude or longitude in MapView, it should be 100000 times the decimal lat or long.

 

Try something like this:

 

double lat_dbl = Double.parseDouble(latitude) * 100000;
double long_dbl = Double.parseDouble(longitude) * 100000;
int lat_int = (int)lat_dbl;
int long_int = (int)long_dbl;
mapView.setLatitude(lat_int);
mapView.setLongitude(long_int);

 

 

__________________________________________________
If my post helped you, make sure to give me kudos by clicking the star below my name! :smileyhappy:
Please use plain text.