3

可能重复:
android 地图上的 iphone 类注释

我正在实现一个使用谷歌地图的应用程序。到目前为止,我已经成功地在谷歌地图上标记了位置。但我真正需要的是在谷歌地图位置的顶部设置一个标题。就像下图一样。

有人可以帮帮我吗?谢谢。

在此处输入图像描述

4

3 回答 3

2

Its basically called Mapview Ballons. Here is the sample project developed on github for your reference. It will help me a lot in my project.

Mapview Ballons

Hope it helps you.

于 2012-12-04T04:55:56.327 回答
0

看看刚刚发布的新的Google Maps Android API v2 。它使添加带有信息窗口(带有标题和片段)的标记变得更加容易 - 请参阅文档以获取示例。

于 2012-12-04T05:28:56.153 回答
0

您可以通过使用 onTap 方法在 ItemizedOverlay 中使用 Alertbox/Dialog 框。

您可以标记任意多个您喜欢的地方,并且可以在谷歌地图位置的顶部设置标题。

例如

    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);
        }
    }
}
于 2012-12-04T05:00:27.453 回答