Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中设置谷歌地图位置的名称和标题_Android_Google Maps_Geolocation_Google Maps Markers - Fatal编程技术网

在Android中设置谷歌地图位置的名称和标题

在Android中设置谷歌地图位置的名称和标题,android,google-maps,geolocation,google-maps-markers,Android,Google Maps,Geolocation,Google Maps Markers,可能重复: 我正在实现一个使用谷歌地图的应用程序。到目前为止,我成功地在谷歌地图上标记了位置。但我真正需要的是在谷歌地图位置的顶部设置一个标题。如下图所示 有人能帮我吗? 谢谢 它基本上被称为Mapview气球。下面是在github上开发的示例项目,供您参考。这将对我的项目有很大帮助 希望对您有所帮助。您可以使用onTap方法在ItemizeOverlay中使用Alertbox/对话框 你可以标记任意多个你喜欢的地方,你也可以在谷歌地图的顶部设置一个标题 例如 public void onC

可能重复:

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

有人能帮我吗? 谢谢


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


希望对您有所帮助。

您可以使用onTap方法在ItemizeOverlay中使用Alertbox/对话框

你可以标记任意多个你喜欢的地方,你也可以在谷歌地图的顶部设置一个标题

例如

public void onCreate(Bundle b)
{
super.onCreate(b);
试试{
setContentView(R.layout.main);
System.out.println(“+lati+place+longi+position.get(0)+position.size());
mapView=(mapView)findViewById(R.id.map\u视图);
mapView.SetBuilTinZoomControl(真);
mc=mapView.getController();
mc.setZoom(12);
drae=this.getResources().getDrawable(R.drawable.ic_启动器);
试验tt=新试验(drae,本);
tt.addit(纬度、经度、地名);
tt.addit(横向1、纵向1、地点名称1);
getOverlays().add(tt);
系统输出打印(二);
打破
}
违约:
System.out.println(position.size());
}
}
}
}捕获(例外e){
System.out.println(e.getMessage());
} 
}
@凌驾
受保护的布尔值isRouteDisplayed(){
返回false;
}
类测试扩展了ItemizeOverlay
{
ListoverLayItem=新的ArrayList();
上下文con;
公共测试(可绘制drae、上下文con){
超级(中央底部(drae));
testt(con);
}
void testt(上下文con)
{
这个.con=con;
}
@凌驾
受保护的OverlayItem createItem(int i){
返回overLayItem.get(i);
}
@凌驾
公共整数大小(){
返回overLayItem.size();
}
受保护的布尔onTap(整数索引){
//TODO自动生成的方法存根
OverlayItem ir=OverlayItem.get(索引);
AlertDialog.Builder直径=新建AlertDialog.Builder(con);
直径setTitle(ir.getTitle());
dia.setMessage(ir.getSnippet());
dia.setPositiveButton(“关闭”,新的DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
//TODO自动生成的方法存根
dialog.dismise();
}
});
直径显示();
返回true;
}
公共无效附加项(覆盖项项)
{
叠加项添加(项);
填充();
}
公共void addit(int l、int g、字符串s)
{
地质点po=新的地质点(l,g);
OverlayItem it=新的OverlayItem(采购订单、采购订单、空);
附加项(it);
}
}
}

看看刚刚发布的新版本。它使添加带有信息窗口(带有标题和代码段)的标记变得更加容易-请参见示例。

您是为iOS还是Android开发的?`MarkerOptions MarkerOptions=new MarkerOptions().position(new LatLng(纬度、经度));标记选项。标题(mapertitle);mMap.addMarker(markerOptions);/*始终显示地图标记标题*/marker marker=mMap.addMarker(markerOptions);marker.showInfoWindow()`谢谢你,蝎子。我给你打一针:D
    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);
        }
    }
}