0

我正在尝试为地图上的点设置我自己的自定义标记,但它们一直作为标记出现"defaultIcon"

在我的主要:

    itemizedOverlay = new OurItemizedOverlay(defaultIcon, this);

将点添加到地图:

public void addPointToMap(PointOfInterest pointOfInterest) {

            mapOverlays.clear();

            pointOfInterest = setMarkerForPointOfInterest(pointOfInterest);         

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

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

    }
4

0 回答 0