我想在方法ViewDidLoad()
中使用MKMapView触摸屏幕时放置一个引脚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;
}
我该怎么做呢? Xamarindocs专门用于放置图像,但如何放置图钉?它不是内置在MKMapView中吗?
答案 0 :(得分:2)
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);