1

I want to refresh my MKOverlay with a new fillColor (hotSpot[@"intensity"]). Is there a way to force call the rendererForOverlay method? It only gets called once when the map is loaded.

-(MKOverlayRenderer*)mapView:(MKMapView*)mapView rendererForOverlay:(id<MKOverlay>) overlay{
    MKPolygonRenderer *square;
    for(NSDictionary *hotSpot in hotSpots) {
        if([overlay.title containsString:hotSpot[@"id"]]) {
            square = [[MKPolygonRenderer alloc] initWithOverlay:overlay];
            square.fillColor = [[UIColor redColor] colorWithAlphaComponent:[hotSpot[@"intensity"] floatValue]];
        }
    }

    return square;
}

I've tried but was not successful with:

[map setNeedsDisplay];

[map setNeedsDisplayInRect:CGRectMake(0,0,map.layer.frame.size.width,map.layer.frame.size.height)];

MKCoordinateRegion region = map.region;
region.span.longitudeDelta /= 1.01;
region.span.latitudeDelta /= 1.01;
[map setRegion:region animated:TRUE];
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Andrew
  • 3,545
  • 4
  • 31
  • 37
  • Instead of setNeedsDisplay, try this: get a reference to the overlay's renderer using the map view's rendererForOverlay: method (not the delegate method) and call invalidatePath on it. –  Feb 19 '15 at 16:38

1 Answers1

3

You could add & remove the same MKOverlay object. That forces a call to rendererForOverlay, even when you have the same overlay.

juanC
  • 46
  • 2