0

I am trying to set my own custom marker for points on a map but they keep coming out as the marker "defaultIcon"

In my main:

    itemizedOverlay = new OurItemizedOverlay(defaultIcon, this);

Add Point to map:

public void addPointToMap(PointOfInterest pointOfInterest) {

            mapOverlays.clear();

            pointOfInterest = setMarkerForPointOfInterest(pointOfInterest);         

            itemizedOverlay.addOverlay(pointOfInterest);
            mapOverlays.add(myLocationOverlay);
            mapOverlays.add(itemizedOverlay);
            mapView.invalidate();
    }

Set marker for OverlayItem

       private PointOfInterest setMarkerForPointOfInterest(PointOfInterest pointOfInterest) {

           String type = pointOfInterest.getType().toLowerCase();

           if(type.equals("monument")) {
               pointOfInterest.setMarker(monumentIcon);
               return pointOfInterest;
           }
           else if(type.equals("building")) {
               pointOfInterest.setMarker(buildingIcon);
               return pointOfInterest;
           }
           else if(type.equals("atm")) {
               pointOfInterest.setMarker(atmIcon);
               return pointOfInterest;
           }
           else if(type.equals("attraction")) {
               pointOfInterest.setMarker(attractionIcon);
               return pointOfInterest;
           }
           else if(type.equals("pub")) {
               pointOfInterest.setMarker(pubIcon);
               return pointOfInterest;
           }
           else if(type.equals("restaurant")) {
               pointOfInterest.setMarker(restaurantIcon);
               return pointOfInterest;
           }
           else if(type.equals("shop")) {
               pointOfInterest.setMarker(shopIcon);
               return pointOfInterest;
           }
           else if(type.equals("bridge")) {
               pointOfInterest.setMarker(bridgeIcon);
               return pointOfInterest;
           }
           else if(type.equals("station")) {
               pointOfInterest.setMarker(stationIcon);
               return pointOfInterest;
           }
           else if(type.equals("cafe")) {
               pointOfInterest.setMarker(cafeIcon);
               return pointOfInterest;
           }
           else if(type.equals("hotel")) {
               pointOfInterest.setMarker(hotelIcon);
               return pointOfInterest;
           }
           else {
               pointOfInterest.setMarker(defaultIcon);
               return pointOfInterest; 
           }

    }
TomSelleck
  • 6,706
  • 22
  • 82
  • 151
  • have you tried logging the value of `type` to make sure it contains the correct string. Also, if the string might contain leading or trailing whitespace, you might also need to do a `trim` – iagreen Jan 29 '13 at 19:44
  • Have you put a breakpoint or debug statement in setMarkerForPointOfInterest to see what the type of the incoming PointOfInterest actually is? – Gabe Sechan Jan 29 '13 at 19:44
  • Hey, I will try trimming now, also I am certain some of the points should match those types. Thanks for the reply – TomSelleck Jan 29 '13 at 19:51
  • "certain" as in "logged it just prior to the if statement" certain? If so, the other options is your POI class is not actually calling through to `getMarker` on your `Overlay` item, or somehow you loaded the same image resource for all your different icons. – iagreen Jan 29 '13 at 20:10
  • Yep I've log.d'd it, my POI class extends OverylayItem – TomSelleck Jan 29 '13 at 20:11

0 Answers0