@Override
    public void draw(final BoundingBox boundingBox, final byte zoomLevel, final Canvas canvas, final Point topLeftPoint, final Rotation rotation) {
        if (coordinates == null) {
            return;
        }

        positionHistory.rememberTrailPosition(coordinates);

        if (Settings.isMapTrail()) {
            final ArrayList<TrailHistoryElement> paintHistory = new ArrayList<>(getHistory());
            // always add current position to drawn history to have a closed connection, even if it's not yet recorded
            paintHistory.add(new TrailHistoryElement(coordinates));
            final int size = paintHistory.size();
            if (size < 2) {
                return;
            }

            final long mapSize = MercatorProjection.getMapSize(zoomLevel, this.displayModel.getTileSize());

            Location prev = paintHistory.get(0).getLocation();
            final Path path = AndroidGraphicFactory.INSTANCE.createPath();
            int current = 1;
            while (current < size) {
                path.moveTo((float) (MercatorProjection.longitudeToPixelX(prev.getLongitude(), mapSize) - topLeftPoint.x), (float) (MercatorProjection.latitudeToPixelY(prev.getLatitude(), mapSize) - topLeftPoint.y));

                boolean paint = false;
                while (!paint && current < size) {
                    final Location now = paintHistory.get(current).getLocation();
                    current++;
                    if (now.distanceTo(prev) < LINE_MAXIMUM_DISTANCE_METERS) {
                        path.lineTo((float) (MercatorProjection.longitudeToPixelX(now.getLongitude(), mapSize) - topLeftPoint.x), (float) (MercatorProjection.latitudeToPixelY(now.getLatitude(), mapSize) - topLeftPoint.y));
                    } else {
                        paint = true;
                    }
                    prev = now;
                }
                if (!path.isEmpty()) {
                    canvas.drawPath(path, historyLine);
                    path.clear();
                }
            }
        }
    }
maximum distance (in meters) up to which two points in the trail get connected by a drawn line
main/src/main/java/cgeo/geocaching/maps/mapsforge/v6/layers/HistoryLayer.java