2012-12-04 55 views

回答

2

它基本上称为MapView的气球。以下是在github上开发的示例项目供您参考。这对我的项目会有很大的帮助。

Mapview Ballons

希望它可以帮助你。

+0

感谢Scorpion。我给你一个镜头:D – bynu022

+0

一切顺利... – Scorpion

0

您可以通过使用方法的onTap使用Alertbox /对话框ItemizedOverlay ..

您可以标记为你喜欢的很多地方,你可以的谷歌地图位置的顶部设置标题。

对于实例

public void onCreate(Bundle b) 
    { 
     super.onCreate(b); 
     try{ 

      setContentView(R.layout.main); 
      System.out.println(""+lati+place+longi+position.get(0)+position.size()); 
      mapView=(MapView)findViewById(R.id.map_view); 
      mapView.setBuiltInZoomControls(true); 

      mc = mapView.getController(); 
      mc.setZoom(12); 

      drae=this.getResources().getDrawable(R.drawable.ic_launcher); 
      test tt=new test(drae,this);   
      tt.addit(latitude,longitude, place_name); 
      tt.addit(latitude1,longitude1, place_name1); 
      mapView.getOverlays().add(tt); 
      System.out.println(ii); 

      break; 
     } 


     default: 
      System.out.println(position.size()); 
     } 
    } 
} 

     }catch (Exception e) { 
      System.out.println(e.getMessage()); 
     } 
    } 

    @Override 
    protected boolean isRouteDisplayed() { 
     return false; 
    } 

    class test extends ItemizedOverlay 
    { 
     List<OverlayItem>overLayItem=new ArrayList<OverlayItem>(); 
     Context con; 
     public test(Drawable drae,Context con) { 

      super(boundCenterBottom(drae)); 
      testt(con); 
     } 

     void testt(Context con) 
     { 
      this.con=con; 
     } 
     @Override 
     protected OverlayItem createItem(int i) { 
      return overLayItem.get(i); 
     } 

     @Override 
     public int size() { 
      return overLayItem.size(); 
     } 

     protected boolean onTap(int index) { 
      // TODO Auto-generated method stub 
      OverlayItem ir=overLayItem.get(index); 
      AlertDialog.Builder dia=new AlertDialog.Builder(con); 
      dia.setTitle(ir.getTitle()); 
      dia.setMessage(ir.getSnippet()); 
      dia.setPositiveButton("close",new DialogInterface.OnClickListener() { 

       public void onClick(DialogInterface dialog, int which) { 
        // TODO Auto-generated method stub 
        dialog.dismiss(); 
       } 
      }); 
      dia.show(); 
      return true; 
     } 


     public void additem(OverlayItem item) 
     { 
      overLayItem.add(item); 
      populate(); 
     } 
     public void addit(int l,int g,String s) 
     { 
      GeoPoint po=new GeoPoint(l, g); 
      OverlayItem it=new OverlayItem(po,s,null); 
      additem(it); 
     } 
    } 
}