public override void ViewDidLoad() { base.ViewDidLoad(); // no XIB ! mapView = new MKMapView() { ShowsUserLocation = true }; labelDistance = new UILabel() { Frame = new RectangleF(10, 5, 292, 44), Lines = 2, BackgroundColor = UIColor.Black, TextColor = UIColor.White }; var segmentedControl = new UISegmentedControl(); segmentedControl.Frame = new RectangleF(20, 360, 282, 30); segmentedControl.InsertSegment("Map", 0, false); segmentedControl.InsertSegment("Satellite", 1, false); segmentedControl.InsertSegment("Hybrid", 2, false); segmentedControl.SelectedSegment = 0; segmentedControl.ControlStyle = UISegmentedControlStyle.Bar; segmentedControl.TintColor = UIColor.DarkGray; segmentedControl.ValueChanged += delegate { if (segmentedControl.SelectedSegment == 0) { mapView.MapType = MonoTouch.MapKit.MKMapType.Standard; } else if (segmentedControl.SelectedSegment == 1) { mapView.MapType = MonoTouch.MapKit.MKMapType.Satellite; } else if (segmentedControl.SelectedSegment == 2) { mapView.MapType = MonoTouch.MapKit.MKMapType.Hybrid; } }; mapView.Delegate = new MapViewDelegate(this); // RegionChanged, GetViewForAnnotation // Set the web view to fit the width of the app. mapView.SizeToFit(); // Reposition and resize the receiver mapView.Frame = new RectangleF(0, 50, this.View.Frame.Width, this.View.Frame.Height - 50); //mapView.SetCenterCoordinate(confLoc, true); MKCoordinateSpan span = new MKCoordinateSpan(0.2, 0.2); MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation, span); mapView.SetRegion(region, true); ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation , "Austin Convention Center" , "500 E Cesar Chavez St, Austin, TX" ); Console.WriteLine("This adds a custom placemark for the Conference Venue"); mapView.AddAnnotationObject(a); locationManager = new CLLocationManager(); locationManager.Delegate = new LocationManagerDelegate(mapView, this); locationManager.StartUpdatingLocation(); // Add the table view as a subview this.View.AddSubview(mapView); this.View.AddSubview(labelDistance); this.View.AddSubview(segmentedControl); // Add the 'info' button to flip Console.WriteLine("make flip button"); var flipButton = UIButton.FromType(UIButtonType.InfoLight); flipButton.Frame = new RectangleF(290, 17, 20, 20); flipButton.Title(UIControlState.Normal); flipButton.TouchDown += delegate { _mfvc.Flip(); }; Console.WriteLine("flipbutton ready to add"); this.View.AddSubview(flipButton); }
public override void ViewDidLoad() { base.ViewDidLoad (); // no XIB ! mapView = new MKMapView() { ShowsUserLocation = true }; labelDistance = new UILabel() { Frame = new RectangleF (10, 5, 292, 44), Lines = 2, BackgroundColor = UIColor.Black, TextColor = UIColor.White }; var segmentedControl = new UISegmentedControl(); segmentedControl.Frame = new RectangleF(20, 360, 282,30); segmentedControl.InsertSegment("Map", 0, false); segmentedControl.InsertSegment("Satellite", 1, false); segmentedControl.InsertSegment("Hybrid", 2, false); segmentedControl.SelectedSegment = 0; segmentedControl.ControlStyle = UISegmentedControlStyle.Bar; segmentedControl.TintColor = UIColor.DarkGray; segmentedControl.ValueChanged += delegate { if (segmentedControl.SelectedSegment == 0) mapView.MapType = MonoTouch.MapKit.MKMapType.Standard; else if (segmentedControl.SelectedSegment == 1) mapView.MapType = MonoTouch.MapKit.MKMapType.Satellite; else if (segmentedControl.SelectedSegment == 2) mapView.MapType = MonoTouch.MapKit.MKMapType.Hybrid; }; mapView.Delegate = new MapViewDelegate(this); // RegionChanged, GetViewForAnnotation // Set the web view to fit the width of the app. mapView.SizeToFit(); // Reposition and resize the receiver mapView.Frame = new RectangleF (0, 50, this.View.Frame.Width, this.View.Frame.Height - 50); //mapView.SetCenterCoordinate(confLoc, true); MKCoordinateSpan span = new MKCoordinateSpan(0.2,0.2); MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation,span); mapView.SetRegion(region, true); ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation , "Austin Convention Center" , "500 E Cesar Chavez St, Austin, TX" ); Console.WriteLine("This adds a custom placemark for the Conference Venue"); mapView.AddAnnotationObject(a); locationManager = new CLLocationManager(); locationManager.Delegate = new LocationManagerDelegate(mapView, this); locationManager.StartUpdatingLocation(); // Add the table view as a subview this.View.AddSubview(mapView); this.View.AddSubview(labelDistance); this.View.AddSubview(segmentedControl); // Add the 'info' button to flip Console.WriteLine("make flip button"); var flipButton = UIButton.FromType(UIButtonType.InfoLight); flipButton.Frame = new RectangleF(290,17,20,20); flipButton.Title (UIControlState.Normal); flipButton.TouchDown += delegate { _mfvc.Flip(); }; Console.WriteLine("flipbutton ready to add"); this.View.AddSubview(flipButton); }
public void SetLocation(MapLocation toLocation) { var loc = toLocation.Location; Console.WriteLine("SetLocation to {0},{1}", loc.Latitude, loc.Longitude); if (loc.Equals(new CLLocationCoordinate2D(0,0))) { // use the 'location manager' current coordinate loc = locationManager.Location.Coordinate; } else if (toLocation.Title == "PCD09") { // no need to drop anything } else { // drop a new pin ConferenceAnnotation a = new ConferenceAnnotation(toLocation.Location, toLocation.Title,toLocation.Subtitle); mapView.AddAnnotationObject(a); } mapView.CenterCoordinate = loc; }