Setting a custom icon with OverlayItem.setMarker() - Android

433 views Asked by At

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

    }
0

There are 0 answers