我正在使用 OSMdroid pathoverlay 在 OSM 地图上绘制路径。我想要的是为路径段赋予不同的颜色。例如第一点和第二点之间的绿色,第二点和第三点之间的红色等。有没有一种简单的方法可以做到这一点,或者我只需要为每两个点绘制路径。这是我的代码:
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setAlpha(90);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(10);
final PathOverlay myPath = new PathOverlay(Color.RED, this);
myPath.setPaint(paint);
GeoPoint pt0 = new GeoPoint(55.50751471753, 37.573947718445);
GeoPoint pt1 = new GeoPoint(55.515894950325, 37.576943422821);
GeoPoint pt2 = new GeoPoint(55.558540269411, 37.589379590206);
GeoPoint pt3 = new GeoPoint(55.560980447657, 37.58950603316);
GeoPoint pt4 = new GeoPoint(55.563488028278, 37.583155265129);
GeoPoint pt5 = new GeoPoint(55.566675052453, 37.574270957266);
myPath.addPoint(pt0);
myPath.addPoint(pt1);
myPath.addPoint(pt2);
myPath.addPoint(pt3);
myPath.addPoint(pt4);
myPath.addPoint(pt5);
mMapView.getOverlays().add(myPath);