title: iOS Google Maps, different custom images for Clusters and individual markers
body: <p>I am using Google Maps SDK in my iOS app. I am populating the map using the clustering methods.</p>
  
  <p>I have set custom images for the different clustering buckets ex. 10,20...</p>
  
  <p>The individual markers however have the default (google maps red marker icon).</p>
  
  <p>I would like a custom icon for clustering and a different one for single markers.</p>
  
  <p>However inside the methods that render the Cluster that add markers, if you set the marker icons it changes all of the images not just singles.</p>
  
  <p>How do I set different icons for singles and clusters?</p>
  
  <p>this adds the items to clusterManager</p>
  
  <pre><code>        id&lt;GMUClusterItem&gt; item =
  [[POIItem alloc] initWithPosition:CLLocationCoordinate2DMake([bay.latitude doubleValue], [bay.longitude doubleValue]) name:bay.name status:bay.marker_status];
  [clusterManager addItem:item];
  </code></pre>
  
  <p>Here I add the icons for the cluster buckets</p>
  
  <pre><code>        - (id&lt;GMUClusterIconGenerator&gt;)iconGeneratorWithImages {
      return [[GMUDefaultClusterIconGenerator alloc] initWithBuckets:@[ @10, @50, @100, @200, @1000 ]
                                                    backgroundImages:@[
                                                                       [UIImage imageNamed:@"big_parking_pin_img"],
                                                                       [UIImage imageNamed:@"big_parking_pin_img"],
                                                                       [UIImage imageNamed:@"big_parking_pin_img"],
                                                                       [UIImage imageNamed:@"big_parking_pin_img"],
                                                                       [UIImage imageNamed:@"big_parking_pin_img"]
                                                                       ]];
  }
  </code></pre>
  
  <p>This is where the google cluster class adds markers </p>
  
  <pre><code>        - (void)renderCluster:(id&lt;GMUCluster&gt;)cluster animated:(BOOL)animated {
    float zoom = _mapView.camera.zoom;
    if ([self shouldRenderAsCluster:cluster atZoom:zoom]) {
      CLLocationCoordinate2D fromPosition;
      if (animated) {
        id&lt;GMUCluster&gt; fromCluster =
            [self overlappingClusterForCluster:cluster itemMap:_itemToOldClusterMap];
        animated = fromCluster != nil;
        fromPosition = fromCluster.position;
      }
  
      UIImage *icon = [_clusterIconGenerator iconForSize:cluster.count];
      GMSMarker *marker = [self markerWithPosition:cluster.position
                                              from:fromPosition
                                          userData:cluster
                                       clusterIcon:icon
                                          animated:animated];
  
      [_markers addObject:marker];
    } else {
      for (id&lt;GMUClusterItem&gt; item in cluster.items) {
        CLLocationCoordinate2D fromPosition;
        BOOL shouldAnimate = animated;
        if (shouldAnimate) {
          GMUWrappingDictionaryKey *key = [[GMUWrappingDictionaryKey alloc] initWithObject:item];
          id&lt;GMUCluster&gt; fromCluster = [_itemToOldClusterMap objectForKey:key];
          shouldAnimate = fromCluster != nil;
          fromPosition = fromCluster.position;
        }
  
        GMSMarker *marker = [self markerWithPosition:item.position
                                                from:fromPosition
                                            userData:item
                                         clusterIcon:nil
                                            animated:shouldAnimate];
        [_markers addObject:marker];
        [_renderedClusterItems addObject:item];
      }
    }
    [_renderedClusters addObject:cluster];
  }
  
  // Returns a marker at final position of |position| with attached |userData|.
  // If animated is YES, animates from the closest point from |points|.
  - (GMSMarker *)markerWithPosition:(CLLocationCoordinate2D)position
                               from:(CLLocationCoordinate2D)from
                           userData:(id)userData
                        clusterIcon:(UIImage *)clusterIcon
                           animated:(BOOL)animated {
    CLLocationCoordinate2D initialPosition = animated ? from : position;
    GMSMarker *marker = [GMSMarker markerWithPosition:initialPosition];
    marker.userData = userData;
    if (clusterIcon != nil) {
      marker.icon = clusterIcon;
      marker.groundAnchor = CGPointMake(0.5, 0.5);
    }
    marker.map = _mapView;
  
    if (animated) {
      [CATransaction begin];
      [CATransaction setAnimationDuration:kGMUAnimationDuration];
      marker.layer.latitude = position.latitude;
      marker.layer.longitude = position.longitude;
      [CATransaction commit];
    }
    return marker;
  }
  </code></pre>