Note that there are some explanatory texts on larger screens.

plurals
  1. POMKMapView and setRegion:animated: not updating the map visuals
    text
    copied!<p>Greetings! I'm attempting to use <strong>MKMapView</strong> without any Apple code samples, though there are a few others out there of varying clarity. (I know, "Read the friendly manual." I've done that but it's not 100% clear, so please bear with me on this one.)</p> <p>Here's the situation. I have a <strong>MKMapView</strong> object, wherein I have added a set of about ten <strong>MKPinAnnotation</strong> objects. So far, so good. Everything is alloced/released sanely and there doesn't appear to be any complaints from Instruments.</p> <p>Upon initial display, I set up a <strong>MKCoordinateRegion</strong> object with the centerpoint at our first pin location, and a (arbitrary) span of 0.2 x 0.2. I then call:</p> <pre><code>[mapView setRegion:region animated:YES]; [mapView regionThatFits:region]; </code></pre> <p>Wow! That worked well. </p> <p>Meanwhile ... I also have a segmented control to allow for movement to each pin location. So as I tap through the list, the map animates to each new pin location with a new pair of calls to <strong>setRegion:animated:</strong> and <strong>regionThatFits:</strong> ... or at least that's the idea.</p> <p>While the map does "travel" to the new pin location, the map itself doesn't update underneath. Instead, I see my pin on a gray/blank-map background ... <em>until</em> I nudge the map in any direction, however slightly. Then the map shows through! (If I'm only moving within a short distance of the previous pin location, I'll usually see whatever part of the map was already loaded.)</p> <p>I suspect I'm doing something dumb here, but I haven't been able to figure out what, at least not from the MapKit docs. Perhaps I'm using the wrong calls? (Well, I do need to set the region at least once, yes? Moving that around doesn't seem to help though.) I have also tried using <strong>setCenterCoordinate:animated:</strong> - same problem.</p> <p>I'm assuming nothing at this point (no pun intended). Just trying to find my way.</p> <p>Clues welcome/appreciated!</p> <p>UPDATE: Calling <strong>setRegion:animated:</strong> and <strong>regionThatFits:</strong> the first time, followed by <strong>setCenterCoordinate:animated:</strong> while traversing the list, has no effect. Interesting finding though: If I change animated to NO in both cases, the map updates!!! Only when it's set to YES. (Wha happen?! Is animated: broken? That can't be ... ???)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload