public PNGOverlay(Bitmap original, GeoPoint topLeftGeoPoint, GeoPoint bottomRightGeoPoint) {
this.original = Bitmap.createScaledBitmap(original, original.getWidth(), original.getHeight(), true);
...
topGeoPoint = topLeftGeoPoint;
bottomGeoPoint = bottomRightGeoPoint;
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, false);
Projection projection = mapView.getProjection();
Point leftTop = new Point();
Point rightTop = new Point();
Point rightBottom = new Point();
Point leftBottom = new Point();
projection.toPixels(topGeoPoint, leftTop);
projection.toPixels(new GeoPoint(topGeoPoint.getLatitudeE6(), bottomGeoPoint.getLongitudeE6()), rightTop);
projection.toPixels(bottomGeoPoint, rightBottom);
projection.toPixels(new GeoPoint(bottomGeoPoint.getLatitudeE6(), topGeoPoint.getLongitudeE6()), leftBottom);
....
Paint paint = new Paint();
paint.setFilterBitmap(true);
paint.setAntiAlias(true);
canvas.drawBitmap(original, null, new Rect(leftTop.x, leftTop.y, rightBottom.x, rightBottom.y), paint);
....
}
我对这段代码有疑问。当我在 mapView 上绘制 png 时,png 图像显示在指南针和 GPS 位置指示器上?任何想法?
最佳答案
从你的问题很难猜出你的问题到底是什么,但如果你的意思是 PNG 被绘制在其他叠加层上并且你希望它在它们下面,你可以通过首先添加 PNG 叠加层来解决它 map View 。
MapView 按照您添加它们的顺序从每个叠加层调用 draw 方法:
mapview.getoverlays().add(overlay1);
mapview.getoverlays().add(overlay2);
这导致 overlay2 被绘制在 overlay1 之上。
mapview.getoverlays().add(overlay2);
mapview.getoverlays().add(overlay1);
这导致 overlay1 被绘制在 overlay2 之上。
祝你好运。
关于Android Png 覆盖问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12629140/