5

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?

scai
  • 20,297
  • 4
  • 56
  • 72
kittu88
  • 2,451
  • 5
  • 40
  • 80
  • Did you check `road.mStatus` or the log? Is `road` an actual route consisting of more than your two points? – scai Apr 29 '14 at 09:25
  • I am getting Road Status(14367): 2 – kittu88 Apr 29 '14 at 09:34
  • And my other question? Can you see the full request to OSRM in your log? Try to execute it in your browser. – scai Apr 29 '14 at 10:59
  • No I can not see the full request. How do I check that? – kittu88 Apr 29 '14 at 11:29
  • when I use this: if (road.mStatus != Road.STATUS_OK){ Log.d("Error", ""+road.mStatus); } I am getting an error in the logcat: 04-29 17:12:19.348: E/BONUSPACK(3529): OSRMRoadManager::getRoad: request failed. 04-29 17:12:19.348: D/Road Status(3529): 2 – kittu88 Apr 29 '14 at 11:39
  • Then please try to create a manual request on [project-osrm.org](http://project-osrm.org) using *the same coordinates* and see if it succeeds. – scai Apr 29 '14 at 12:51
  • Yes, it is showing a route – kittu88 Apr 30 '14 at 10:43

0 Answers0