当我有大变焦时,我的应用程序滞后问题。 我有标记和区域的地图,当我制作缩放比例时,地图是滞后的。 我一直在寻找解决方案,但我找不到。
请帮我这个代码。
我不知道如何解决它。
这是我的代码:
public class LiniaOverlay extends Overlay {
private List<GeoPoint> m_areas;
private Paint m_paintFill;
private Paint m_paintStroke;
private static final int ALPHA = 0x30ffffff;
private static int COLORS = Color.YELLOW;
Path areaPaths;
static {LiniaOverlay.COLORS &= LiniaOverlay.ALPHA;}
public LiniaOverlay(final List<GeoPoint> points) {
m_areas = points;
m_paintFill = new Paint();
m_paintFill.setStyle(Paint.Style.FILL);
m_paintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
m_paintStroke.setStyle(Style.STROKE);
m_paintStroke.setAntiAlias(true);
m_paintStroke.setStrokeWidth(3);
}
@Override
public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) {
super.draw(canvas, mapView, shadow);
if (shadow) {
return;
}
Projection projection = mapView.getProjection();
areaPaths = getPath(projection, m_areas);
drawPaths(canvas, areaPaths);
}
private Path getPath(final Projection projection, final List<GeoPoint> areas) {
Path path = new Path();
path.setFillType(Path.FillType.EVEN_ODD);
Iterator<GeoPoint> it = areas.iterator();
Point point = nextDrawPoint(projection, it);
path.moveTo(point.x, point.y);
while (it.hasNext())
{
point = nextDrawPoint(projection, it);
path.lineTo(point.x, point.y);
}
path.close();
return path;
}
private void drawPaths(final Canvas canvas, final Path path) {
int currentColor = LiniaOverlay.COLORS;
m_paintStroke.setColor(currentColor & 0xff7f7f7f);
canvas.drawPath(path, m_paintStroke);
int currentColor2 = LiniaOverlay.COLORS;
m_paintFill.setColor(currentColor2);
canvas.drawPath(path, m_paintFill);
}
private Point nextDrawPoint(final Projection projection, final Iterator<GeoPoint> it) {
GeoPoint geo = it.next();
Point p = new Point();
projection.toPixels(geo, p);
return p;
}
}
请帮助我。