我使用了我的SitesOverlay类的draw()
方法,该方法正在扩展ItemizedOverlay<OverlayItem>
以绘制一些线条。现在,我还将多个图像作为叠加层添加到地图中,方法是将这一个图像添加到许多不同点的List<OverlayItem>
。
现在发生的是,无论线条(使用draw()
方法绘制)和图像图标重叠,都会在叠加图像上绘制线条。
如何使叠加图像位于顶部?
编辑:我使用populate()将所有叠加层放在地图上,只要我将它们添加到列表中即可。有没有什么方法可以在之后调用填充我使用了draw()方法?我尝试将populate放入draw()方法,但应用程序停止工作......其他方式?
答案 0 :(得分:0)
我在这里分享我的来源
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, shadow);
try {
for (int i = 0; i < size(); i++) {
OverlayItem item = getItem(i);
String driverName = item.getSnippet();
Data.activlyShownDrivers.add(driverName);
Point screenPts = new Point();
mapView.getProjection().toPixels(item.getPoint(), screenPts);
Bitmap bmp = null;
Context ctx = ShowAll.getContext();
long angle = (long) Double.parseDouble(item.getTitle());
// ---add the marker---
bmp = BitmapFactory.decodeResource(ctx.getResources(),
R.drawable.img1);
Paint paint = new Paint();
paint.setColor(Color.BLACK);
paint.setStyle(Style.FILL_AND_STROKE);
canvas.drawBitmap(bmp, screenPts.x, screenPts.y, null);
canvas.drawText(driverName, screenPts.x, screenPts.y, paint);
}
// }
} catch (Exception e) {
try {
Log.e(Data.LOG, e.getMessage());
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
答案 1 :(得分:0)
嗯,它表明如果你使用的是draw方法,那么无论你使用它绘制什么,都将被覆盖在你的叠加层上。这是因为每次拖动/缩放或对地图执行任何操作时都会调用draw()
,并且仅在开头填充叠加层...因此使用draw()
绘制的线将始终覆盖叠加层。