可能重复:
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