1

I am unable to get a route displayed on a Osmdroid map displayed on an Android 4.3 smartphone. I am using osmbonuspack v4.4 jar and osmdroid-android v4.1 jar. I have overriden/copied OSRMRoadManager to CarRouteManager so that it makes use of the java.net.HttpURLConnection instead of the Apache HTTPConnection. With Apache HTTPConnection I don't get any route information back but with the java.net.HttpURLConnection I get route information back. The road has a mStatus of STATUS_OK and I can see the various parts of the route when I debug my code. The route drawing function is the following:

public void DrawDirection(Road road)
{
    if (road.mStatus == Road.STATUS_OK)
    {
        current_route = CarRouteManager.buildRoadOverlay(road, Color.BLUE, 3, this);
        current_route.addPoint(user_point);
        current_route.addPoint(clicked_location);
        map_view.getOverlays().add(current_route);          
        map_view.invalidate();
    }
}

With the above code I just get two polylines displayed on the map, one which traces straight from the GeoPoint user_point(starting point) to the GeoPoint clicked_location (destination). The other polyline traces to the right-bottom of the screen and off the current map area that is visible, when I zoom out to the world map it extends all the way off the edge of the map at Antartica. When I remove the two lines

current_route.addPoint(user_point);

and

current_route.addPoint(clicked_location);

then there are no polylines drawn on the map. I have debugged the contents of current_route (which is of type PathOverlay) and the points in the mPoints array are valid GeoPoints, i.e. not null. When I map these GeoPoints onto the Google map at https://maps.google.com/ then it shows that these GeoPoints are valid locations on the roads/route between GeoPoint user_point(starting point) and GeoPoint clicked_location (destination).

Has anybody suffered the same affect and managed to solve it?

solarrobor
  • 11
  • 1
  • 6

1 Answers1

1

I would recommend you to:

  • get rid of your CarRouteManager stuff
  • just follow closely the OSMBonusPack tutorial
  • taking care about the "Important Note" at the very beginning of the Tutorials.

If you still have issues, have a look here: RoadManager for osmdroid error

Only when you will have a better understanding of the inner behaviour of the lib, you will be able to implement your own RouteManager (if really needed).

Community
  • 1
  • 1
MKer
  • 3,430
  • 1
  • 13
  • 18
  • The json file I get back from pasting the url in the browser comes back as having some of the street names empty, but the first three "parts" have street names. At least these three paths should show on the map? – solarrobor Apr 22 '14 at 18:00
  • Forgot to add that the missing street names are in the route_instructions section of the json file. – solarrobor Apr 22 '14 at 18:11
  • Using the OSMBonusPackTutorial and placing in the coordinates of the two GeoPoints that I would like to have a route drawn for, I get a nice route drawn. If I replace my CarRouteManager with the OSRMRoadManager and use the exact same code parts(comment 1. and comment 2.) as in the OSMBonusPackTutorial the road I get back has a mStatus of STATUS_DEFAULT and no route is drawn. Zoom level and tile source are the same. – solarrobor Apr 23 '14 at 13:41