2

I am currently making an open street map android project. I have been following tutorials on getting a route between two co-ordinates on a map, but when i run my code a route from point A to point B is not displayed. What is displayed on the map is a straight line from point A to B.

link to tutorial: https://github.com/MKergall/osmbonuspack/wiki/Tutorial_1

my code     
  RoadManager mRoadManager = new OSRMRoadManager(this);
        ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
        waypoints.add(start);
        GeoPoint endpoint = new GeoPoint(41.4,-1.9);
        waypoints.add(endpoint);
        Road road = mRoadManager.getRoad(waypoints);
        Polyline roadOverlay = RoadManager.buildRoadOverlay(road);
        mMapview.getOverlays().add(roadOverlay);
        mMapview.invalidate();
    }

Based on the tutorial I expected the directions from A to B to be displayed. Can anyone spot what I'm doing wrong or recommend a routing API that I can use.

I have found this error in logcat:

E/BONUSPACK: OSRMRoadManager::getRoad: request failed.

I bumped into a person with the same issue, it is explained better on his thread link: https://github.com/MKergall/osmbonuspack/issues/218

Josef Adamcik
  • 5,620
  • 3
  • 36
  • 42
  • 1
    Welcome to the StackOverflow. The straight line means that the request to the backend service that actually does the route computation failed as you can also see in the included line from logcat. Check out this answer to the same problem: https://stackoverflow.com/a/21894178/135837 and go through all points mentioned there. You could also include bigger part of your logcat (more lines following after `OSRMRoadManager::getRoad: request failed.` since there might be more details about the problem. And also check if your app actually has network permission. – Josef Adamcik Feb 10 '19 at 10:46
  • 2
    Thank you @JosefAdamcik this was very helpful. I found out what the problem is, I was missing the following line in the manifest " android:usesCleartextTraffic="true" " – Best Runner Feb 10 '19 at 12:45
  • android:usesCleartextTraffic="true" is absolutely irrelevant when using OSRMRoadManager. The most probable reason for your problem to be solved is that OSRM service was up again. – MKer Feb 18 '19 at 17:29

0 Answers0