我在地图视图中添加了多个椭圆,使用下面的代码,但我想添加气泡标记图像(或任何任何标记),在这种情况下如何使用图像。 在叠加层中:
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
try{
Projection projection = mapView.getProjection();
super.draw(canvas, mapView, shadow);
// Create and setup your paint brush
Paint paint = new Paint();
paint.setARGB(250, 255, 0, 0);
paint.setAntiAlias(true);
paint.setFakeBoldText(true);
if (shadow == false) {
for (GeoPoint point : array_Locations) {
Point myPoint = new Point();
projection.toPixels(point, myPoint);
RectF oval = new RectF(myPoint.x-rad,
myPoint.y-rad, myPoint.x+rad, myPoint.y+rad);
canvas.drawOval(oval, paint);
canvas.drawText( "place of interest", myPoint.x, myPoint.y, paint);
}
}
}
catch (Exception ex) {
ex.toString();
}
地图活动中的:
mapView.getOverlays().add(new HelloItemizedOverlay(cursor));
答案 0 :(得分:1)
您可以在覆盖类构造函数(在您的案例中为HelloItemizedOverlay)中执行此操作,而不是在onDraw()中添加气泡。
例如,请参阅此处的代码MapView with balloons。