ItemizedOverlay with ArrayList doesnt work

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

ItemizedOverlay with ArrayList doesnt work

Postby Raa » Sun May 15, 2011 1:35 pm

hi guys,

im a bit desprate i cant find the reason why my ItemizedOverlay only shows one item. The strange thing is - it shows only one mark on the map... but there are 100% for sure 3 Items in the ArrayList list!

Does anybody has an idea ?
No Error is shown...

Code: Select all
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.powerstation);

         MapView mapView = (MapView) findViewById(R.id.mapview);


        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable = this.getResources().getDrawable(R.drawable.icon);
        PowerStationOverlay itemizedoverlay = new PowerStationOverlay(drawable);

        ArrayList<locations.PowerStation> list = getPS();
//        list.add(new locations.PowerStation(19240000, -99120000));
//        list.add(new locations.PowerStation(35410000, 139460000));

        GeoPoint gp;

        for(locations.PowerStation ps : list){
            gp = new GeoPoint(ps.getLat(), ps.getLon());
            itemizedoverlay.addOverlay(new OverlayItem(gp, "Sekai, konichiwa!", "I'm in Japan!"));

        }

        mapOverlays.add(itemizedoverlay);

}


Code: Select all
package locations;

import android.content.Context;
import android.graphics.drawable.Drawable;
import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

import java.util.ArrayList;

/**
* Created by IntelliJ IDEA.
* User: raa
* Date: 15.05.11
* Time: 12:42
* To change this template use File | Settings | File Templates.
*/
public class PowerStationOverlay extends ItemizedOverlay{

    private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
    Context mContext;
    @Override
    protected OverlayItem createItem(int i) {
        return mOverlays.get(i);
    }

    @Override
    public int size() {
        return mOverlays.size();
    }

    public PowerStationOverlay(Drawable defaultMarker) {
        super(boundCenterBottom(defaultMarker));

    }

    public PowerStationOverlay(Drawable defaultMarker, Context context) {
        super(defaultMarker);
        mContext = context;

}

    public void addOverlay(OverlayItem overlay) {
        mOverlays.add(overlay);
        populate();
}

    @Override
protected boolean onTap(int index) {
  OverlayItem item = mOverlays.get(index);

  return true;
}
}
Raa
Freshman
Freshman
 
Posts: 7
Joined: Thu Oct 14, 2010 9:52 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 3 guests