I have created an App using OSM map. The app is working fine, but the route from my current location to the destination is showing up as a straight line and not through any roads.
The method I am using:
public void addRouteOverlay(GeoPoint startPoint, GeoPoint endPoint) {
// road manager
RoadManager roadManager = new OSRMRoadManager();
// start and end points
ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
waypoints.add(startPoint);
// GeoPoint endPoint = new GeoPoint(48.4, -1.9);
waypoints.add(endPoint);
// roadManager.addRequestOption("routeType=bicycle");
// retreive the road between those points
Road road = roadManager.getRoad(waypoints);
if (road.mStatus != Road.STATUS_OK){
Log.d("Road Status", ""+road.mStatus);
}
// Polyline with the route shape
org.osmdroid.bonuspack.overlays.Polyline roadOverlay = RoadManager
.buildRoadOverlay(road, this);
// Polyline to the overlays of your map
mapView.getOverlays().add(roadOverlay);
// Refresh the map
mapView.invalidate();
The way I am calling the method:
//to display route between current location and destination
addRouteOverlay(new GeoPoint(location.getLatitude(),
location.getLongitude()), new GeoPoint(22.566039700000000000,
88.349356700000040000));
What should I do get the desired route between my location and destination?