In this recipe, we will learn how to add a red circle overlay over a point on the map.
Create a new Single View Application in Xamarin Studio and name it MapOverlayApp
. Add MKMapView
and a button on the controller.
Perform the following steps to add overlays on the map:
Add the
MonoTouch.MapKit
andMonoTouch.CoreLocation
namespaces in theMapOverlayAppViewController.cs
file.Add the
IMKMapViewDelegate
interface to the class declaration using the following code:public partial class MapOverlayAppViewController : UIViewController, IMKMapViewDelegate
Add the following code in the
ViewDidLoad
method:this.mapView.ShowsUserLocation = true; this.mapView.WeakDelegate = this; this.btnAddOverlay.TouchUpInside += (sender, e) => { CLLocationCoordinate2D mapCoordinate = this.mapView.UserLocation.Coordinate; this.mapView.SetRegion(MKCoordinateRegion.FromDistance(mapCoordinate, 1000, 1000), true); MKCircle circle = MKCircle.Circle(mapCoordinate...