Xamarin.ios 在地图视图中放置图钉
我想在ViewDidLoad()方法中使用MKMapView在触摸屏幕时放置一个pin 我该怎么做呢?Xamarin文档对放置图像有明确规定,但如何放置pin?它不是内置在MKMapView中吗?您添加了一个Xamarin.ios 在地图视图中放置图钉,xamarin.ios,xamarin,Xamarin.ios,Xamarin,我想在ViewDidLoad()方法中使用MKMapView在触摸屏幕时放置一个pin 我该怎么做呢?Xamarin文档对放置图像有明确规定,但如何放置pin?它不是内置在MKMapView中吗?您添加了一个 public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically fro
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
mapView.ShowsUserLocation = true;
MKUserLocation currentLocation = mapView.UserLocation;
}
class BasicMapAnnotation : MKAnnotation{
public override CLLocationCoordinate2D Coordinate {get;set;}
string title, subtitle;
public override string Title { get{ return title; }}
public override string Subtitle { get{ return subtitle; }}
public BasicMapAnnotation (CLLocationCoordinate2D coordinate, string title, string subtitle) {
this.Coordinate = coordinate;
this.title = title;
this.subtitle = subtitle;
}
}
var annotation = new BasicMapAnnotation (new CLLocationCoordinate2D(48.857,2.351), "Paris", "City of Light");
mapView.AddAnnotation(annotation);