2012-11-27 110 views
2

我已經在我的項目的問題,我不知道如何顯示在谷歌地圖與MYSQL數據庫經緯度數據的多個標誌..如何在谷歌地圖Android上顯示多個標記?

這裏使用數組列表代碼:

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

回答

0

我認爲你可以創建一個類作爲Positions來獲取屬性

對於Position類,調用方法來檢索地理位置點,方法是使用關鍵字作爲搜索位置並返回地理位置 - 地址

0

使用這個課堂我喜歡它: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);