2012-03-02 69 views
0

我想繪製地圖上的一些geepoints之間的路徑,同時我通過geopoints的數組列表迭代。從這我收到索引超出界限的錯誤,我累了調試它,但沒有得到任何地方。那麼請有人指出我正確的方向,並感謝你。使用地圖疊加和GeoPoints在地圖視圖上的Android繪圖路徑

//making the array and inserting the geopoints 
List <GeoPoint> points = new ArrayList<GeoPoint>(); 
    for (Iterator<Placemark> iter=places.iterator();iter.hasNext();) { 
     Placemark point = (Placemark)iter.next(); 

     points.add(new GeoPoint(p.getLatitude(),p.getLongitude())); 


    } 
//the loop which gives out a null exception 
for (int j=0; j <points.size(); j++){ 
MyOverlay poin = new MyOverlay(points.get(j-1),points.get(j)); } 

回答

0

使用這樣的循環,

for (int j=0; j <points.size()-1; j++){ 
MyOverlay poin = new MyOverlay(points.get(j),points.get(j+1)); } 

如果仍然沒有奏效,試試這個在for循環,

j<points.size()-2 
+0

爲(INT J = 1;Ĵ<點.size(); j ++){ MyOverlay poin = new MyOverlay(points.get(j-1),points.get(j)); } – jay 2012-03-04 00:49:41

+0

兩人都可以工作先生,祝你好運 – 2012-03-04 13:18:51