本文整理汇总了C#中MKMapView.AddOverlay方法的典型用法代码示例。如果您正苦于以下问题:C# MKMapView.AddOverlay方法的具体用法?C# MKMapView.AddOverlay怎么用?C# MKMapView.AddOverlay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MKMapView
的用法示例。
在下文中一共展示了MKMapView.AddOverlay方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
// add the map view
var map = new MKMapView(UIScreen.MainScreen.Bounds);
View.Add(map);
// change the map style
map.MapType = MKMapType.Standard;
// enable/disable interactions
// map.ZoomEnabled = false;
// map.ScrollEnabled = false;
// show user location
if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) {
locationManager.RequestWhenInUseAuthorization();
}
map.ShowsUserLocation = true;
// specify a custom map delegate
var mapDelegate = new MyMapDelegate();
map.Delegate = mapDelegate;
// add a point annotation
map.AddAnnotation(new MKPointAnnotation()
{
Title = "MyAnnotation",
Coordinate = new CLLocationCoordinate2D(42.364260, -71.120824)
});
// add a custom annotation
// map.AddAnnotation(new CustomAnnotation("CustomSpot", new CLLocationCoordinate2D(38.364260, -68.120824)));
// TODO: Step 4a - draw a circle overlay
var circleOverlay = MKCircle.Circle(new CLLocationCoordinate2D(33.755, -84.39), 100 * 1609.34); // 1609.34 = meters in a mile
map.AddOverlay(circleOverlay);
// TODO: Step 4b - draw a polygon (Wyoming)
var stateOverlay = MKPolygon.FromCoordinates(new CLLocationCoordinate2D[]
{
new CLLocationCoordinate2D(45.00, -111.00),
new CLLocationCoordinate2D(45, -104),
new CLLocationCoordinate2D(41, -104),
new CLLocationCoordinate2D(41, -111)
});
map.AddOverlay(stateOverlay);
}
示例2: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
Title = "Pyramids of Giza";
mapView = new MKMapView(View.Bounds);
mapView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
View.AddSubview(mapView);
var coords = new CLLocationCoordinate2D(29.976111, 31.132778); // pyramids of giza, egypt
var span = new MKCoordinateSpan(MilesToLatitudeDegrees(.75), MilesToLongitudeDegrees(.75, coords.Latitude));
// set the coords and zoom on the map
mapView.MapType = MKMapType.Satellite;
mapView.Region = new MKCoordinateRegion(coords, span);
mapView.OverlayRenderer = (m, o) => {
if(circleRenderer == null)
{
circleRenderer = new MKCircleRenderer(o as MKCircle);
circleRenderer.FillColor = UIColor.Purple;
circleRenderer.Alpha = 0.5f;
}
return circleRenderer;
};
circleOverlay = MKCircle.Circle (coords, 200);
mapView.AddOverlay (circleOverlay);
#region Not related to this sample
int typesWidth=260, typesHeight=30, distanceFromBottom=60;
mapTypes = new UISegmentedControl(new CGRect((View.Bounds.Width-typesWidth)/2, View.Bounds.Height-distanceFromBottom, typesWidth, typesHeight));
mapTypes.InsertSegment("Road", 0, false);
mapTypes.InsertSegment("Satellite", 1, false);
mapTypes.InsertSegment("Hybrid", 2, false);
mapTypes.SelectedSegment = 1; // Road is the default
mapTypes.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
mapTypes.ValueChanged += (s, e) => {
switch(mapTypes.SelectedSegment) {
case 0:
mapView.MapType = MKMapType.Standard;
break;
case 1:
mapView.MapType = MKMapType.Satellite;
break;
case 2:
mapView.MapType = MKMapType.Hybrid;
break;
}
};
View.AddSubview(mapTypes);
#endregion
}
示例3: ViewDidLoad
public override void ViewDidLoad()
{
base.ViewDidLoad ();
//
// Create our map view and add it as as subview.
//
_mapView = new MKMapView();
_mapView.Frame = new RectangleF (0, 0, this.View.Frame.Width, this.View.Frame.Height);
View.AddSubview(_mapView);
_mapView.Delegate = new MapViewDelegate(this);
LoadRoute();
if (RouteLine != null)
{
_mapView.AddOverlay(RouteLine);
}
ZoomInOnRoute();
}