osmbonus包中的路线折线是不可见的

时间:2015-01-06 12:48:38

标签: android dictionary routing osmdroid

尝试通过osmbonus包进行路由,一切都工作得很好,但有一个问题是我看不到绘制的折线作为我地图上的路线。 我确定自(mRoadOverlay.getNumberOfPoints())返回41

以来已经生成了它

我正在关注OSMNavigator示例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);
        }

另外我需要说我可以在地图上看到道路节点,所以可以说road是正确的

1 个答案:

答案 0 :(得分:0)

供将来参考:

我找到了原因, 原因是为了扩大我使用这个自定义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/"}));

其中我将aTileSizePixel更改为512,而我的瓷砖实际上是256x256 ...这有助于我展示更大的瓷砖,因此更大的字体大小,纬度和经度都没问题,因为我可以自己设置点数地图在确切的位置,也是路线节点没有问题,然而路线Polyline本身并没有,我想它已被装载在一个不同的位置,而这个位置并不在我查看的视图中。