【发布时间】:2015-02-09 14:54:08
【问题描述】:
我正在使用 graphhopper 和 mapsforge 在我的 android 应用程序中显示路线。路线从折线显示在我的 mapView 中,但是当我更改第二点的位置时,新路线显示在上一条路线上方。所以我需要在计算新路线时删除这条先前的路线。代码如下:
GraphHopper localGraphHopper = new GraphHopper().forMobile();
localGraphHopper.setCHShortcuts(true, true);
localGraphHopper.load(getFolderPath());
GHRequest localGHRequest = new GHRequest(paramDouble1, paramDouble2, paramDouble3, paramDouble4);
GHRequest a = localGHRequest.setAlgorithm("dijkstrabi");
GHResponse localGHResponse = localGraphHopper.route(localGHRequest);
int i = localGHResponse.getPoints().getSize();
PointList localPointList = localGHResponse.getPoints();
Polyline localPolyline = new Polyline(createPaint(AndroidGraphicFactory.INSTANCE.createColor(Color.RED), 4, Style.STROKE), AndroidGraphicFactory.INSTANCE);
this.latLongs_track = localPolyline.getLatLongs();
for (int j = 0;; j++)
{
if (j >= i)
{
this.mapView.getLayerManager().getLayers().add(localPolyline);
LatLong localLatLong = new LatLong((paramDouble1 + paramDouble3) / 2.0D, (paramDouble2 + paramDouble4) / 2.0D);
this.mapView.getModel().mapViewPosition.setCenter(localLatLong);
return;
}
this.latLongs_track.add(new LatLong(localPointList.getLatitude(j), localPointList.getLongitude(j)));
}
【问题讨论】:
-
你有什么问题?
-
创建新路线时需要删除之前的路线
标签: android routing polyline graphhopper mapsforge