Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set width for PathOverlay lines (OSMDroid)

Does anyone know how to set the width of a line for a PathOverlay element in OSMDroid?

The PathOverlay class itself doesn't really have anything useful in that arena. I've trying going into the Paint and Canvas used by PathOverlay's draw method. The android.graphics.Paint class has a setStrokeWidth(float) method, but that has no effect on the line width.

Looking through the Paint API, there isn't much else there that helps; likewise for the Canvas.

like image 483
Richard Avatar asked Aug 05 '26 12:08

Richard


1 Answers

Try the following (you can adapt to your requirements);

    pathOverlay = new PathOverlay(Color.GREEN, context);
    ArrayList<GeoPoint> path = getTrackPoints();
    mMapView.getOverlays().add(pathOverlay);
    Paint pPaint = pathOverlay.getPaint();
    pPaint.setStrokeWidth(5);
    pathOverlay.setPaint(pPaint);

If you get the Paint settings from the overlay and then just modify the width it solves having to worry about other Paint settings

like image 101
Rory Mapstone Avatar answered Aug 07 '26 04:08

Rory Mapstone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!