我正在尝试使用Mapsforge在我的Android应用中绘制一种简单的方法,一条路线。我遵循了一个示例,并创建了单点OverlayItems。但是,当我尝试绘制路线时,我的地图上看不到任何东西。有谁能够帮助我?这是我的简单代码:

    Paint wayPaint = new Paint();
    wayPaint.setColor(color.Chocolate);
    ArrayWayOverlay wayOverlay = new ArrayWayOverlay(wayPaint,wayPaint);
    GeoPoint gp1 = new GeoPoint(41.38, 2.15);
    GeoPoint gp2 = new GeoPoint(41.39, 2.15);
    GeoPoint gp3 = new GeoPoint(41.40, 2.15);
    GeoPoint gp4 = new GeoPoint(41.41, 2.15);
    OverlayWay way = new OverlayWay(new GeoPoint[][] { { gp1, gp2, gp3, gp4 } });
    wayOverlay.addWay(way);
    mapView.getOverlays().add(wayOverlay);


我不知道我是否必须在某些地方放置标记...

最佳答案

尝试设置wayPaint Style和笔触宽度,如下所示:

Paint wayPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
wayPaint.setStyle(Paint.Style.STROKE);
wayPaint.setColor(Color.BLUE);
wayPaint.setAlpha(192);
wayPaint.setStrokeWidth(6);
wayDefaultPaintFill.setStrokeJoin(Paint.Join.MITER);

ArrayWayOverlay wayOverlay = new ArrayWayOverlay(wayPaint,wayPaint);
//your points
OverlayWay way = new OverlayWay(new GeoPoint[][] { {geoPoint1,geoPoint2,... } });
wayOverlay.addWay(way);
mapView.Overlays().add(wayOverlay);


希望这可以帮助!

关于android - 使用Mapsforge绘制OverlayWay,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16708071/

10-10 20:15