Search code examples
iosmkmapviewmkoverlay

Re-adding overlays on Map View iOS


I have a problem. Imagine that you are getting overlay polygon data (latitudes and longtitudes) and drawing overlay on map View. [mapView addOverlays:overlayArray];

Drawing overlays on polygon is easy. However, if you draw overlays with timer with different overlays that is complicated. Because you dont want your overlay to be drawn on the previous overlays. if you add and remove then flickering happens!!!

Image that you are creating weather radar map.

How do they achieve this consecutive(timer) overlays drawings? any idea(s)? thanks in advance.


Solution

  • Have you taken a look at MKMapView reference? http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html

    there are methods described which you can use to manipulate the overlays array. That way, you don't have to add and remove the whole array.

    Edit: Adding and Removing Overlays

    – addOverlay:
    – addOverlays:
    – removeOverlay:
    – removeOverlays:
    – insertOverlay:atIndex:
    – exchangeOverlayAtIndex:withOverlayAtIndex:
    – insertOverlay:aboveOverlay:
    – insertOverlay:belowOverlay:
    – viewForOverlay: