【问题标题】:How to show the multiple marker on google maps Android?如何在谷歌地图 Android 上显示多个标记?
【发布时间】:2012-11-14 20:18:35
【问题描述】:

我的项目有问题,我不知道如何使用数据库 mySql 中的纬度和经度数据在谷歌地图上显示多个标记..

这里是使用数组列表的代码:

private class SitesOverlay extends ItemizedOverlay<OverlayItem> {
    private List<OverlayItem> items=new ArrayList<OverlayItem>();

    public SitesOverlay(Drawable marker) {
      super(marker);

      boundCenterBottom(marker);


      //i want change this, calling the data from mysql automatically
      items.add(new OverlayItem(getPoint(40.748963847316034,
                                          -73.96807193756104),
                                "UN", "United Nations"));
      items.add(new OverlayItem(getPoint(40.76866299974387,
                                          -73.98268461227417),
                                "Lincoln Center",
                                "Home of Jazz at Lincoln Center"));
      items.add(new OverlayItem(getPoint(40.765136435316755,
                                          -73.97989511489868),
                                "Carnegie Hall",
              "Where you go with practice, practice, practice"));
      items.add(new OverlayItem(getPoint(40.70686417491799,
                                          -74.01572942733765),
                                "The Downtown Club",
                        "Original home of the Heisman Trophy"));

      populate();
    }

【问题讨论】:

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


    【解决方案1】:

    我认为你可以创建一个类作为 Positions 来获取属性

    对于Position类,调用获取地理位置点的方法,实现以关键词为搜索位置的函数,返回地理位置

    【讨论】:

      【解决方案2】:

      使用我喜欢的这个类:https://github.com/jgilfelt/android-mapviewballoons,它有例子。

      SimpleItemizedOverlay itemizedoverlay = new MyItemizedOverlay(drawable, this);
      GeoPoint point = new GeoPoint((int)(37.878901f * 1e6),(int)(-4.779396 * 1e6));
      OverlayItem overlayitem = new OverlayItem(point, "Hello, World!", "I'm in Spain!");
      .
      .
      .
      GeoPoint point = new GeoPoint((int)(37.878901f * 1e6),(int)(-4.779396 * 1e6));
      OverlayItem overlayitem = new OverlayItem(point, "Hello, World!", "I'm in Spain!");
      
      itemizedoverlay.addOverlay(overlayitem);
      mapOverlays.add(itemizedoverlay);
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-02-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-11-04
        • 2015-02-11
        相关资源
        最近更新 更多