Last active
December 20, 2015 14:29
-
-
Save lobrien/6147243 to your computer and use it in GitHub Desktop.
Shows a race condition in MapKit. You cannot rely on the map.CenterCoordinate in synchronous code, and it's not clear to me what event (if any) is associated with the `UIMapView.CenterCoordinate` becoming set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var map = new MKMapView(); | |
var ctr = new CLLocationCoordinate2D(37.8, -122.4); | |
map.SetCenterCoordinate(ctr, false); | |
map.SetRegion(new MKCoordinateRegion(ctr, new MKCoordinateSpan(0.025, 0.025)), false); | |
Console.WriteLine("Center coordinate is still NaN: " + map.CenterCoordinate.Latitude.ToString()); | |
/* | |
Error: NaN Lat & Long var | |
circle = MKCircle.Circle(map.CenterCoordinate, 100); | |
Must use explicit location instead, a la: | |
*/ | |
var circle = MKCircle.Circle(ctr, 100); | |
map.AddOverlay(circle); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment