I want to call the method buildRoadOverlay
(Method is on the bottom of this post) from OSMdroid. How do I set the parameters correctly?
This method builds a route on a map between two waypoints. It works, as long as I leave out color and width when calling the method. Now I want the color to be green and the width to be 20dp.
This is how I tried it:
Polyline roadOverlay = RoadManager.buildRoadOverlay(road, 7667507, 20);
The app starts, no errors, but the Line RoadOverlay does not get drawn anymore. Either that or it is invisible. I am not sure.
The method I want to call:
public static Polyline buildRoadOverlay(Road road, int color, float width){
Polyline roadOverlay = new Polyline();
roadOverlay.setColor(color);
roadOverlay.setWidth(width);
if (road != null) {
ArrayList<GeoPoint> polyline = road.mRouteHigh;
roadOverlay.setPoints(polyline);
}
return roadOverlay;
}
color is an Android Color. width is a float, in pixels. So try:
Polyline roadOverlay = RoadManager.buildRoadOverlay(road, Color.GREEN, 20.0f);
Putting some transparency on road shape is recommended, so that street names for instance remain visible. So this will be better:
Polyline roadOverlay = RoadManager.buildRoadOverlay(road, 0x8000FF00, 20.0f);
(and yes, I apologize for the javadoc of this method. I will improve it)