使用地图叠加和GeoPoints在mapview上绘制Android绘图路径

时间:2012-03-02 22:45:42

标签: android-layout overlay android-mapview

我试图在地图上的一些geepoints之间绘制一条路径,同时我遍历地理点的arraylist。从这个我收到一个索引越界错误,我已经厌倦调试它但没有得到任何地方。那么有人可以指出我正确的方向,谢谢你。

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

1 个答案:

答案 0 :(得分: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
相关问题