【问题标题】:Route Polyline in osmbonus pack is invisibleosmbonus 包中的路线折线不可见
【发布时间】:2015-01-06 12:48:38
【问题描述】:

在这里尝试通过 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 是正确的

【问题讨论】:

    标签: android dictionary routing osmdroid


    【解决方案1】:

    供将来参考:

    我找到了原因, 原因是为了放大地图的字体大小,我使用了这个自定义的 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 ...这有助于我显示更大的图块,因此更大的字体大小,纬度和经度都可以,因为我可以自己设置点准确位置的地图,路线节点也很好,但折线路线本身却不是,我猜它已加载到我检查过的视图中没有的不同位置。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-14
      • 2023-03-23
      相关资源
      最近更新 更多