Skip to content

Commit

Permalink
Create a MKMapView and zoom it on update
Browse files Browse the repository at this point in the history
  • Loading branch information
anaisbetts committed Jul 8, 2012
1 parent 64849bf commit a4e5ba1
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 124 deletions.
13 changes: 12 additions & 1 deletion Whereami/Whereami/WhereamiViewController.cs
Expand Up @@ -4,6 +4,7 @@
using MonoTouch.Foundation;
using MonoTouch.CoreLocation;
using MonoTouch.UIKit;
using MonoTouch.MapKit;

namespace Whereami
{
Expand All @@ -29,8 +30,10 @@ public override void ViewDidLoad ()

locationManager = new CLLocationManager();
locationManager.DesiredAccuracy = 0.2;
locationManager.StartUpdatingLocation();
locationManager.Delegate = new WhereAmILocationDelegate();

worldView.ShowsUserLocation = true;
worldView.Delegate = new WhereAmIMapKitDelegate();
}

public override void ViewDidUnload ()
Expand Down Expand Up @@ -64,4 +67,12 @@ public override void Failed (CLLocationManager manager, NSError error)
Console.WriteLine("Could not find location: {0}", error);
}
}

public class WhereAmIMapKitDelegate : MKMapViewDelegate
{
public override void DidUpdateUserLocation (MKMapView mapView, MKUserLocation userLocation)
{
mapView.SetRegion(new MKCoordinateRegion(userLocation.Coordinate, new MKCoordinateSpan(0.1, 0.1)), true);
}
}
}
38 changes: 31 additions & 7 deletions Whereami/Whereami/WhereamiViewController.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a4e5ba1

Please sign in to comment.