I have an app that tracks a users movements and plots the points on a custom map.
I have an issue where after a period of hours the device gets very slow and eventually runs out of memory.
My question is what would be the best way to draw only the points / lines that are visible?
My drawing code is
using (var linePaint = new SKPaint())
{
linePaint.Style = SKPaintStyle.Stroke;
linePaint.Color = SKColors.White;
linePaint.StrokeJoin = SKStrokeJoin.Round;
linePaint.StrokeCap = SKStrokeCap.Round;
linePaint.StrokeWidth = lineWidth * 2f;
Point previousPoint = null;
foreach (var point in localPoints)
{
if (previousPoint == null)
{
previousPoint = point;
continue;
}
canvas.DrawLine(previousPoint.X, previousPoint.Y, point.X, point.Y,
linePaint);
previousPoint = point;
}
How can this be reduced to only drawing points in view?