In this recipe, we will learn how to display maps in our app.
Perform the following steps to display maps in the app:
Add
MKMapView
on the controller. The following screenshot shows the symbol forMKMapView
in Xcode's object library:Add the following
using
directives in theMapDisplayAppViewController.cs
file:using MonoTouch.MapKit; using MonoTouch.CoreLocation;
Enter the following code in the
MapDisplayAppViewController
class:public override void ViewDidLoad () { base.ViewDidLoad (); this.mapView.ShowsUserLocation = true; this.mapView.RegionChanged += this.MapView_RegionChanged; } private void MapView_RegionChanged (object sender, MKMapViewChangeEventArgs e) { if (this.mapView.UserLocation.Location != null) { CLLocationCoordinate2D mapCoordinate = this.mapView.UserLocation.Location.Coordinate; Console.WriteLine("Current coordinates: LAT: {0}, LON: ...