【问题标题】:Set Name and Title on google map position in Android [duplicate]在Android中的谷歌地图位置上设置名称和标题[重复]
【发布时间】:2012-11-21 16:28:39
【问题描述】:

可能重复:
iphone like annotation on android map

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

谁能帮帮我? 谢谢。

【问题讨论】:

  • 您是为 iOS 还是 Android 开发?
  • ` MarkerOptions markerOptions = new MarkerOptions().position(new LatLng(Latitude, longitude)); markerOptions.title(mapMarkerTitle); mmap.addMarker(markerOptions); /* 始终显示地图标记标题 */ Marker marker = mMap.addMarker(markerOptions);标记.showInfoWindow(); `

标签: android google-maps geolocation google-maps-markers


【解决方案1】:

它基本上称为 Mapview Ballons。这是在github上开发的示例项目,供大家参考。这对我的项目有很大帮助。

Mapview Ballons

希望对你有所帮助。

【讨论】:

  • 谢谢蝎子。我试一试:D
【解决方案2】:

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

【讨论】:

    【解决方案3】:

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

    您可以标记任意数量的地点,并且可以在 google 地图位置的顶部设置标题。

    举例

        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);
            }
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2011-04-27
      • 2013-12-08
      • 2014-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多