Problems setting up OSMDroid when following instructions

I use the following code to overlay a route overlay on an OSM droid map using the code obtained from the following tutorial ( http://code.google.com/p/osmbonuspack/wiki/Tutorial_1 ) but slightly modified to a custom method, not used in the OnCrerate method.

Now this is the route and creates a green overlay on the map. However, there is a problem manifested in For Loop onwards. This is because road.mNodes is always zero, indicating that the instructions do not go down.

By the way, I also inspected RoadNodes and RoadItems, and both of them were also zero. This means that bubbles (ExtendedOVerlayItems) are never displayed on the route.

Any advice is appreciated.

//====================================================================================================== /** * Add a route overlay between two geopoints with Bubble overlays on the route points. * * @param startPoint Route start. * @param endPoint Route end. *// //====================================================================================================== public void addRouteOverlay(GeoPoint startPoint, GeoPoint endPoint) { //1 Routing via road manager RoadManager roadManager = new OSRMRoadManager(); roadManager.addRequestOption("routeType=bicycle"); //Then, retreive the road between your start and end point: ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>(); waypoints.add(startPoint); waypoints.add(endPoint); //end point Road road = roadManager.getRoad(waypoints); // then, build an overlay with the route shape: PathOverlay roadOverlay = RoadManager.buildRoadOverlay(road, map.getContext()); roadOverlay.setColor(Color.GREEN); //Add Route Overlays into map map.getOverlays().add(roadOverlay); map.invalidate();//refesh map Drawable marker = ctx.getResources().getDrawable(R.drawable.map_marker_blue); final ArrayList<ExtendedOverlayItem> roadItems = new ArrayList<ExtendedOverlayItem>(); ItemizedOverlayWithBubble<ExtendedOverlayItem> roadNodes = new ItemizedOverlayWithBubble<ExtendedOverlayItem>(ctx, roadItems, map); for (int i=0; i<road.mNodes.size(); i++) { RoadNode node = road.mNodes.get(i); ExtendedOverlayItem nodeMarker = new ExtendedOverlayItem("Step "+i, "", node.mLocation, ctx); nodeMarker.setMarkerHotspot(OverlayItem.HotspotPlace.CENTER); nodeMarker.setMarker(marker); roadNodes.addItem(nodeMarker); nodeMarker.setDescription(node.mInstructions); nodeMarker.setSubDescription(road.getLengthDurationText(node.mLength, node.mDuration)); Drawable icon = ctx.getResources().getDrawable(R.drawable.ic_continue); nodeMarker.setImage(icon); }//end for map.getOverlays().add(roadNodes); }//=================================================================================================== 
+1
source share
1 answer

I had this problem today and she managed to solve it. The problem is the old version of the bonus package. I updated the osmbonuspack_v4.1.jar version from osmbonuspack_v3.8.jar and solved the problem. I also used the MapQuestRoadManager () parameter as opposed to OSRMRoadManager (). However, it should be borne in mind that at the same time some of the supertype methods changed in the bonus packaging - for example, the onOpen () method for ExtendedOverlayItem its parameter will be passed after the call.

 final RoadManager manager= new MapQuestRoadManager(); manager.addRequestOption("routeType=fastest"); 
0
source

All Articles