public override void ViewDidLoad() { base.ViewDidLoad(); float toolbarHeight = 40; float width = View.Bounds.Width; float height = View.Bounds.Height - toolbarHeight - 52; currentAnnotationView = null; mapView = new MKMapView(); mapView.Frame = new RectangleF(0, 0, width, height); mapView.MapType = MKMapType.Satellite; mapView.Delegate = new MapViewDelegate(this); var points = new List <PointAnnotation>(); geometry = new Geometry(points); //initialize geometryMapView which will catch touch Events geometryTouchView = new GeometryTouchView(new RectangleF(0, 0, width, height)); geometryTouchView.BackgroundColor = UIColor.Clear; geometryTouchView.MapView = mapView; geometryTouchView.geometry = geometry; View.AddSubview(mapView); View.AddSubview(geometryTouchView); mapBarButton = new UIBarButtonItem("Move Map", UIBarButtonItemStyle.Bordered, MapBarButtonPressed); pointBarButton = new UIBarButtonItem("Point", UIBarButtonItemStyle.Bordered, PointBarButtonPressed); lineBarButton = new UIBarButtonItem("Line", UIBarButtonItemStyle.Bordered, LineBarButtonPressed); polygonBarButton = new UIBarButtonItem("Polygon", UIBarButtonItemStyle.Bordered, PolygonBarButtonPressed); toolbar = new UIToolbar(new RectangleF(0, height, width, toolbarHeight)); toolbar.Items = new UIBarButtonItem[] { mapBarButton, pointBarButton, lineBarButton, polygonBarButton }; View.AddSubview(toolbar); MapBarButtonPressed(null, null); }
public override void ViewDidLoad() { base.ViewDidLoad(); float toolbarHeight = 40; float width = View.Bounds.Width; float height = View.Bounds.Height - toolbarHeight - 52; currentAnnotationView = null; mapView = new MKMapView (); mapView.Frame = new RectangleF (0,0,width,height); mapView.MapType = MKMapType.Satellite; mapView.Delegate = new MapViewDelegate(this); var points = new List<PointAnnotation>(); geometry = new Geometry(points); //initialize geometryMapView which will catch touch Events geometryTouchView = new GeometryTouchView(new RectangleF(0,0,width,height)); geometryTouchView.BackgroundColor = UIColor.Clear; geometryTouchView.MapView = mapView; geometryTouchView.geometry = geometry; View.AddSubview(mapView); View.AddSubview(geometryTouchView); mapBarButton = new UIBarButtonItem("Move Map", UIBarButtonItemStyle.Bordered, MapBarButtonPressed); pointBarButton = new UIBarButtonItem("Point", UIBarButtonItemStyle.Bordered, PointBarButtonPressed); lineBarButton = new UIBarButtonItem("Line", UIBarButtonItemStyle.Bordered, LineBarButtonPressed); polygonBarButton = new UIBarButtonItem("Polygon", UIBarButtonItemStyle.Bordered, PolygonBarButtonPressed); toolbar = new UIToolbar (new RectangleF(0,height,width,toolbarHeight)); toolbar.Items = new UIBarButtonItem[] {mapBarButton, pointBarButton, lineBarButton, polygonBarButton}; View.AddSubview(toolbar); MapBarButtonPressed(null,null); }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation) { MKAnnotationView annotationView = null; if (annotation is PointAnnotation) { Debug.WriteLine("it's a pin class"); } else if (annotation is GeometryAnnotation) { Debug.WriteLine("it's a line class"); GeometryAnnotation geometryAnnotation = annotation as GeometryAnnotation; LinePolygonAnnotationView _annotationView = new LinePolygonAnnotationView( new RectangleF(0, 0, mapView.Frame.Size.Width, mapView.Frame.Size.Height)); _annotationView.Annotation = geometryAnnotation; _annotationView.MapView = mapView; _viewController.currentAnnotationView = _annotationView; annotationView = _annotationView; } return(annotationView); }
public override MKAnnotationView GetViewForAnnotation(MKMapView mapView, NSObject annotation) { MKAnnotationView annotationView = null; if (annotation is PointAnnotation) { Debug.WriteLine("it's a pin class"); } else if (annotation is GeometryAnnotation) { Debug.WriteLine("it's a line class"); GeometryAnnotation geometryAnnotation = annotation as GeometryAnnotation; LinePolygonAnnotationView _annotationView = new LinePolygonAnnotationView( new RectangleF(0,0,mapView.Frame.Size.Width, mapView.Frame.Size.Height)); _annotationView.Annotation = geometryAnnotation; _annotationView.MapView = mapView; _viewController.currentAnnotationView = _annotationView; annotationView = _annotationView; } return annotationView; }