9

I have an MKOverlayView that displays animated radar data as a series of images. The issue I have is that the radar images are chopped into tiles by MapKit. To swap images I have a timer that calls an update function which sets the current image in my overlay and then calls the following

[myRadarOverlayView setNeedsDisplayInMapRect:self.mapView.visibleMapRect];

The overlay updates, but does so one tile at a time so I get a choppy animation. Any ideas about how make all the tiles animate (i.e. swap images) at the exact same time?

Aaron
  • 2,345
  • 1
  • 22
  • 24

3 Answers3

6

I solved this by adding a UIImageView as a subview of the MKOverlayView.

  • To animate, stop drawing with the normal drawMapRect:zoomScale:inContext: (via an instance variable/property flag) and draw to the UIImageView instead (to the animationImages property), then use startAnimating.

  • You can handle panning and zooming by reinitializing the UIImageView in response to mapView:regionDidChangeAnimated:.

shawkinaw
  • 3,151
  • 2
  • 25
  • 30
  • 2
    I'm banging my head on this one too, do you have some sample code to share? I think I'm not setting the frame/bounds right causing the UIImageView not to be shown. – botteaap Dec 30 '11 at 14:53
  • I was able to use this code here: https://github.com/yickhong/YHMapDemo and this code here: http://code.google.com/p/sugartin-info/downloads/detail?name=RadarOverLay.zip&can=2&q combined together to get the result described in this answer. – sridvijay Dec 29 '12 at 03:34
  • @shawkinaw Could you offer some advice on my question about animating in overlays for map view http://stackoverflow.com/questions/20558591/animated-gif-not-working-in-mkmapview-overlay-using-mkoverlayrenderer?noredirect=1#comment30789828_20558591? – wigging Dec 18 '13 at 04:47
  • I have tried both of the links @Gavin and also from sridvijay and got radar image appears here but still it takes time to load approx 15-20 secs and got this warning ": CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces.". Any help will be greatly appreciated – Harsh Thakur Apr 10 '15 at 11:42
4

Sample code how to animate a circle:

http://yickhong-ios.blogspot.com/2012/04/animated-circle-on-mkmapview.html

Shmidt
  • 15,652
  • 16
  • 79
  • 129
0

Is there a callback when all the tiles have finished loading? If so, you could go with double buffering, and update the view offscreen, and then switch it in.

Snips
  • 6,063
  • 6
  • 36
  • 56