Draw a smooth line between geotomes on Android

I drew a line between the geotomes. it has been successfully deleted. when we see the map, the downward line looks like it is jagged when adjacent to the next scroll. how to merge a string?

enter image description here

My code is here

@Override public void draw(Canvas canvas, MapView mapview, boolean shadow) { super.draw(canvas, mapview, shadow); if(! routeIsActive) return; mapview.getProjection().toPixels(locpoint, pp); // Converts GeoPoint to screen pixels int xoff = 0; int yoff = 0; int oldx = pp.x; int oldy = pp.y; int newx = oldx + xoff; int newy = oldy + yoff; paint.setAntiAlias(true); paint.setDither(true); paint.setStrokeWidth(7); for(int i=0; i<numberRoutePoints-1; i++) { switch(routeMode.get(i)) { case 0: paint.setColor(Color.parseColor("#666666")); break; case 1: paint.setColor(Color.parseColor("#0EA7D6")); break; case 2: paint.setColor(Color.parseColor("#654321")); break; case 3: paint.setColor(Color.parseColor("#123456")); break; } mapview.getProjection().toPixels(routePoints.get(i), pold); oldx = pold.x; oldy = pold.y; mapview.getProjection().toPixels(routePoints.get(i+1), pnew); newx = pnew.x; newy = pnew.y; canvas.drawLine(oldx, oldy, newx, newy, paint); } } 
+6
source share
2 answers

You should change the style of the drawing object as follows:

 paint.setStrokeCap(Cap.ROUND); 
+3
source

If you draw a circle at the beginning and at the end of each line (the diameter of the circle should be the height of the line), I think it will do the trick or maybe drawRoundRect of the canvas can do it well

+2
source

Source: https://habr.com/ru/post/921486/


All Articles