【发布时间】: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