可能重複:
iphone like annotation on android map集名稱和Android的谷歌地圖上的位置標題
我實現了使用谷歌maps.To應用程序的那一刻我是能夠成功地標記谷歌地圖上的位置。但我真正需要的是在谷歌地圖位置之上設置標題。就像下面的圖片一樣。
有人可以幫我嗎? 謝謝。
可能重複:
iphone like annotation on android map集名稱和Android的谷歌地圖上的位置標題
我實現了使用谷歌maps.To應用程序的那一刻我是能夠成功地標記谷歌地圖上的位置。但我真正需要的是在谷歌地圖位置之上設置標題。就像下面的圖片一樣。
有人可以幫我嗎? 謝謝。
您可以通過使用方法的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);
}
}
}
看看剛發佈了新的Google Maps Android API v2。它使添加標記與信息窗口(標題和代碼片段)更容易 - 例如,請參閱documentation。
您正在爲iOS或Android開發嗎? – user1032613
Im使用android – bynu022