03-14-2011 01:55 AM
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.
03-14-2011 03:26 PM
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);