Note that there are some explanatory texts on larger screens.

plurals
  1. POOSMDroid Routing problems when following a tutorial
    primarykey
    data
    text
    <p>I utilise the following code to put a route overlay onto an OSM droid map, using code gotten from the following tutorial (<a href="http://code.google.com/p/osmbonuspack/wiki/Tutorial_1" rel="nofollow">http://code.google.com/p/osmbonuspack/wiki/Tutorial_1</a>) but slightly tweaked into a custom method, rather than being used in the OnCrerate method.</p> <p>Now this does route and produces a green overlay on the map. However, there is a problem exhibited from the For Loop onwards. This is because road.mNodes is always size zero indicating that no instructions are coming down.</p> <p>Incidently I also inspected RoadNodes and RoadItems and both were also size zero. This means the bubbles (ExtendedOVerlayItems) are never displayed on the route.</p> <p>Any advice would be greatly appreciated.</p> <pre><code>//====================================================================================================== /** * 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&lt;GeoPoint&gt; waypoints = new ArrayList&lt;GeoPoint&gt;(); 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&lt;ExtendedOverlayItem&gt; roadItems = new ArrayList&lt;ExtendedOverlayItem&gt;(); ItemizedOverlayWithBubble&lt;ExtendedOverlayItem&gt; roadNodes = new ItemizedOverlayWithBubble&lt;ExtendedOverlayItem&gt;(ctx, roadItems, map); for (int i=0; i&lt;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); }//=================================================================================================== </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload