2011-12-14 71 views
0

我已通過使用下面的代碼在地圖視圖中添加了多個橢圓,但是我想添加氣泡標記圖像(或任何任何標記)在此情況下如何使用圖像。 在覆蓋類:使用地圖上的顏色添加標記圖像

@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

http://developer.android.com/resources/tutorials/views/hello-mapview.html – 2011-12-14 11:03:23

回答

1

而是在的onDraw(),你可以做你的覆蓋類的構造函數中添加泡沫(你的情況HelloItemizedOverlay)的。

例如查看這裏的代碼MapView with balloons

相關問題