Search code examples
androiddictionaryroutesosmdroid

Route Polyline in osmbonus pack is invisible


Trying to routing via osmbonus pack here, everything works almost fine, but there is a problem which is I can not see the polyline drawn as the route on my map. I'm sure it has een generated since (mRoadOverlay.getNumberOfPoints()) returns 41

And I'm following the OSMNavigator Sample https://code.google.com/p/osmbonuspack/source/browse/trunk/OSMNavigator/src/com/osmnavigator/MapActivity.java

void updateUIWithRoad(Road road){
            mRoadNodeMarkers.getItems().clear();
            TextView textView = (TextView)findViewById(R.id.tv_main_routeInfo);
            textView.setText("");
            List<Overlay> mapOverlays = map.getOverlays();
            if (mRoadOverlay != null){
                Log.d("Polylinenopoin",String.valueOf(mRoadOverlay.getNumberOfPoints()));
                mapOverlays.remove(mRoadOverlay);
                mRoadOverlay = null;
                Log.d("POLYLINE","1");
            }
            if (road == null){
                return;}
            if (road.mStatus == Road.STATUS_TECHNICAL_ISSUE)
                Toast.makeText(map.getContext(), "Technical issue when getting the route", Toast.LENGTH_SHORT).show();
            else if (road.mStatus > Road.STATUS_TECHNICAL_ISSUE) //functional issues
                Toast.makeText(map.getContext(), "No possible route here", Toast.LENGTH_SHORT).show();
            mRoadOverlay = RoadManager.buildRoadOverlay(road, Main.this);

            String routeDesc = road.getLengthDurationText(-1);
            mRoadOverlay.setTitle("route" + " - " + routeDesc);
            String det = String.valueOf(mRoadOverlay.getColor()) + "- " + String.valueOf(mRoadOverlay.getWidth());
            Log.d("Polydet",det);
            map.getOverlays().add(mRoadOverlay);
            //we insert the road overlay at the "bottom", just above the MapEventsOverlay,
            //to avoid covering the other overlays.
            putRoadNodes(road);
            map.invalidate();
            //Set route info in the text view:
            textView.setText(routeDesc);
        }

Also I need to say that I can see road Nodes on the map, so it's safe to say that road is correct


Solution

  • For future reference:

    I found the reason, the reason was that to enlarge the font size of the maps I used this custom XYTileSource:

    map.setTileSource(new XYTileSource("Google Terrian",
                    ResourceProxy.string.bing, 10, 17, 512, ".jpg", new String[] {
                    "http://otile1.mqcdn.com/tiles/1.0.0/map/",
                    "http://otile2.mqcdn.com/tiles/1.0.0/map/",
                    "http://otile3.mqcdn.com/tiles/1.0.0/map/",
                    "http://otile4.mqcdn.com/tiles/1.0.0/map/"}));
    

    in which I had changed the aTileSizePixel to 512, while my tiles were in fact 256x256 ... this helped me to show tiles bigger and hence bigger font size, the latitude and longitude were alright as I could set points by myself on the map in exact location, also the route Nodes were alright, the route Polyline itself however was not, I guess it had been loaded in a different location which was not in the view I had checked.