Overlay not showing markers

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

Overlay not showing markers

Postby lesmond » Mon Jul 05, 2010 7:39 pm

Hello, I have the following code and the markers are not appearing on the map at all!
Code: Select all
private class SitesOverlay extends ItemizedOverlay<pfOverlayItem> {
      
      private List<pfOverlayItem> items=new ArrayList<pfOverlayItem>();
      //private   PopupPanel panel=new PopupPanel(R.layout.popup);
      
      public SitesOverlay() {
         super(null);
         
         items = mainOverlayArray;
         
         populate();
         
      }
      
      @Override
      protected pfOverlayItem createItem(int i) {
         return(items.get(i));
      }
      
      @Override
      public void draw(Canvas canvas, MapView mapView,
                                 boolean shadow) {
         super.draw(canvas, mapView, shadow);
         
      }
      
      
      @Override
      public int size() {
         
         return(items.size());
         
      }
      
      
      
      private Drawable getMarker(int resource) {
         Drawable marker=getResources().getDrawable(resource);
         
         marker.setBounds(0, 0, marker.getIntrinsicWidth(),
                                    marker.getIntrinsicHeight());
         boundCenter(marker);

         return(marker);
      }
   }


mainOverlayArray is full of pfOverlayItem's and the code for that class is
Code: Select all
public class pfOverlayItem extends OverlayItem {
   private String coolText;
   
   public String getcoolText() {
        return coolText;
    }
   
    public void setcoolText(String coolText) {
        this.coolText = coolText;
    }
   
   public pfOverlayItem(GeoPoint point, String title, String snippet) {
      super(point, title, snippet);
      // TODO Auto-generated constructor stub
   }

}


I also set the marker outside of this after processing an XML file...
Code: Select all
ArrayList<pfOverlayItem> overArray = myXMLHandler.getOverlayArray();
               mainOverlayArray = overArray;
               pfOverlayItem tempOver = null;
               Drawable marker = getResources().getDrawable(R.drawable.icon);
               for (int i = 0; i < mainOverlayArray.size(); i++) {
                  tempOver = mainOverlayArray.get(i);
                  tempOver.setMarker(marker);
               }
               
               sites=new SitesOverlay();
               myMapView.getOverlays().add(sites);
               myMapView.invalidate();   


Someone please help!

Thanks.

Lee
lesmond
Junior Developer
Junior Developer
 
Posts: 11
Joined: Thu Jul 01, 2010 7:26 am

Top

Re: Overlay not showing markers

Postby lesmond » Mon Jul 05, 2010 9:54 pm

I have just found that the following block does not fire....
Code: Select all
private Drawable getMarker(int resource) {
         Drawable marker=getResources().getDrawable(resource);
         
         marker.setBounds(0, 0, marker.getIntrinsicWidth(),
                                    marker.getIntrinsicHeight());
         boundCenter(marker);

         return(marker);
      }


Manually running marker.setBounds(0, 0, marker.getIntrinsicWidth(),
marker.getIntrinsicHeight());

when creating the Drawable works. Any idea why this method is not being called?
lesmond
Junior Developer
Junior Developer
 
Posts: 11
Joined: Thu Jul 01, 2010 7:26 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 3 guests