I am trying to write a code that draws the road that the user have walked. I can get all the coordinates that user have passed now I have to implement the drawing road. But before doing it I have to know how to pass real world coordinates to BB screen as pixels. Can you give me a little information about it ?
Thank you
Here this the code that I have got all the coordinates of the road.
public RoutePaint() {
locations = new Vector();
locVector = new ButtonField("Locations Vector",
ButtonField.CONSUME_CLICK);
locVector.setChangeListener(this);
pixel.setChangeListener(this);
add(locVector);
add(pixel);
myCriteria = new BlackBerryCriteria(GPSInfo.GPS_MODE_AUTONOMOUS);
try {
myProvider = (BlackBerryLocationProvider) LocationProvider
.getInstance(myCriteria);
} catch (LocationException e) {
e.printStackTrace();
}
myProvider.setLocationListener(this, 3, -1, -1);
}
public void locationUpdated(LocationProvider provider, Location location) {
// TODO Auto-generated method stub
point = new Point();
latitude = location.getQualifiedCoordinates().getLatitude();
altitude = location.getQualifiedCoordinates().getAltitude();
longitude = location.getQualifiedCoordinates().getLongitude();
velocity = location.getSpeed();
point.x = latitude;
point.y = longitude;
locations.addElement(point);
invalidate();
}
The following is the code to convert coordinates to screen pixels:
where we assume that latitude and longitude are saved in variables _latitude and _longitude respectively.integer variable x and y consists converted screen pixels from coordinates.