public override void ViewDidLoad() { mapView = new MKMapView(); RectangleF frame = new RectangleF(0,0,320,360); mapView.Frame = frame; mapView.ShowsUserLocation = true; var myAnnotation = new MyAnnotation(new CLLocationCoordinate2D(0,0), "Home", "is where the heart is"); mapView.AddAnnotationObject(myAnnotation); UIButton detailButton = UIButton.FromType(UIButtonType.DetailDisclosure); mapView.GetViewForAnnotation = delegate(MKMapView mapViewForAnnotation, NSObject annotation) { var anv = mapView.DequeueReusableAnnotation("thislocation"); if (anv == null) { anv = new MKPinAnnotationView(annotation, "thislocation"); detailButton.TouchUpInside += (s, e) => { Console.WriteLine ("Tapped"); }; anv.RightCalloutAccessoryView = detailButton; } else { anv.Annotation = annotation; } anv.CanShowCallout = true; return anv; }; View.AddSubview(mapView); }
static public void FindMe(MKMapView map, string markerText) { map.Delegate = new MapViewDelegate(); map.SetCenterCoordinate(CurrentLocation, true); map.Region = new MKCoordinateRegion(CurrentLocation, new MKCoordinateSpan(0.005, 0.005)); map.SetCenterCoordinate(CurrentLocation, true); var meAnn = new SpotAnnotation(CurrentLocation, markerText, ""); map.AddAnnotationObject(meAnn); }
public void UpdateLocation(CLLocationCoordinate2D newLocation, bool animated) { var span = new MKCoordinateSpan(0.1, 0.1); var region = new MKCoordinateRegion(newLocation, span); _mapView.SetRegion(region, animated); if (_geocodeAnnotation != null) { _mapView.RemoveAnnotation(_geocodeAnnotation); } _geocodeAnnotation = new MapViewAnnotation(newLocation); _mapView.AddAnnotationObject(_geocodeAnnotation); }
public override void ViewDidLoad() { base.ViewDidLoad(); var map = new MKMapView(new RectangleF(20, 166, 280, 192)); this.View.Add(map); map.ShowsUserLocation = true; map.MapType = MKMapType.Standard; map.Delegate = new MapViewDelegate(); var location = new CLLocationCoordinate2D(ViewModel.Latitude, ViewModel.Longitude); //map.SetCenterCoordinate(location, true); map.SetRegion(new MKCoordinateRegion(location, new MKCoordinateSpan(0.1, 0.1)), true); var annotation = new MyAnnotation( location , ViewModel.SharedTextSource.GetText("AppTitle") , ViewModel.Name); map.AddAnnotationObject(annotation); Button1.SetImage(UIImage.FromFile("ConfResources/Images/appbar.link.png"), UIControlState.Normal); Button2.SetImage(UIImage.FromFile("ConfResources/Images/appbar.phone.png"), UIControlState.Normal); Button3.SetImage(UIImage.FromFile("ConfResources/Images/appbar.feature.email.rest.png"), UIControlState.Normal); this.AddBindings(new Dictionary <object, string>() { { Label1, "{'Text':{'Path':'Name'}}" }, { Button1, "{'Title':{'Path':'Address'}}" }, { Button2, "{'Title':{'Path':'Phone'}}" }, { Button3, "{'Title':{'Path':'Email'}}" }, }); this.AddBindings(new Dictionary <object, string>() { { Button1, "{'TouchDown':{'Path':'WebPageCommand'}}" }, { Button2, "{'TouchDown':{'Path':'PhoneCommand'}}" }, { Button3, "{'TouchDown':{'Path':'EmailCommand'}}" }, }); NavigationItem.SetRightBarButtonItem(new UIBarButtonItem("Tweet", UIBarButtonItemStyle.Bordered, (sender, e) => ViewModel.ShareGeneralCommand.Execute()), false); }
public override void ViewDidLoad() { base.ViewDidLoad(); var map = new MKMapView(new RectangleF(20, 166, 280, 192)); this.View.Add(map); map.ShowsUserLocation = true; map.MapType = MKMapType.Standard; map.Delegate = new MapViewDelegate(); var location = new CLLocationCoordinate2D(ViewModel.Latitude, ViewModel.Longitude); //map.SetCenterCoordinate(location, true); map.SetRegion(new MKCoordinateRegion(location, new MKCoordinateSpan(0.1, 0.1)), true); var annotation = new MyAnnotation( location , ViewModel.SharedTextSource.GetText("AppTitle") , ViewModel.Name); map.AddAnnotationObject(annotation); Button1.SetImage(UIImage.FromFile("ConfResources/Images/appbar.link.png"), UIControlState.Normal); Button2.SetImage(UIImage.FromFile("ConfResources/Images/appbar.phone.png"), UIControlState.Normal); Button3.SetImage(UIImage.FromFile("ConfResources/Images/appbar.feature.email.rest.png"), UIControlState.Normal); this.AddBindings(new Dictionary<object, string>() { {Label1,"Text Name"}, {Button1,"Title Address"}, {Button2,"Title Phone"}, {Button3,"Title Email"}, }); this.AddBindings(new Dictionary<object, string>() { {Button1,"TouchUpInside WebPageCommand"}, {Button2,"TouchUpInside PhoneCommand"}, {Button3,"TouchUpInside EmailCommand"}, }); NavigationItem.SetRightBarButtonItem(new UIBarButtonItem("Tweet", UIBarButtonItemStyle.Bordered, (sender, e) => ViewModel.DoShareGeneral()), false); }
public override void ViewDidLoad() { mapView = new MKMapView(); RectangleF frame = new RectangleF(0, 0, 320, 360); mapView.Frame = frame; mapView.ShowsUserLocation = true; var myAnnotation = new MyAnnotation(new CLLocationCoordinate2D(0, 0), "Home", "is where the heart is"); mapView.AddAnnotationObject(myAnnotation); UIButton detailButton = UIButton.FromType(UIButtonType.DetailDisclosure); mapView.GetViewForAnnotation = delegate(MKMapView mapViewForAnnotation, NSObject annotation) { var anv = mapView.DequeueReusableAnnotation("thislocation"); if (anv == null) { anv = new MKPinAnnotationView(annotation, "thislocation"); detailButton.TouchUpInside += (s, e) => { Console.WriteLine("Tapped"); }; anv.RightCalloutAccessoryView = detailButton; } else { anv.Annotation = annotation; } anv.CanShowCallout = true; return(anv); }; View.AddSubview(mapView); }
public override void ViewDidLoad() { base.ViewDidLoad (); mapView = new MKMapView() { ShowsUserLocation = true }; labelDistance = new UILabel() { Frame = new RectangleF (0, 0, 320, 49), Lines = 2, BackgroundColor = UIColor.Black, TextColor = UIColor.White }; var segmentedControl = new UISegmentedControl(); var topOfSegement = View.Frame.Height - 120; segmentedControl.Frame = new RectangleF(20, topOfSegement, 282, 30); segmentedControl.InsertSegment("Map".GetText(), 0, false); segmentedControl.InsertSegment("Satellite".GetText(), 1, false); segmentedControl.InsertSegment("Hybrid".GetText(), 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); // Set the web view to fit the width of the app. mapView.SizeToFit(); // Reposition and resize the receiver mapView.Frame = new RectangleF (0, 50, View.Frame.Width, View.Frame.Height - 100); MKCoordinateSpan span = new MKCoordinateSpan(0.01,0.01); MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation,span); mapView.SetRegion(region, true); ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation , "CodeCampSDQ" , "INTEC" ); mapView.AddAnnotationObject(a); locationManager = new CLLocationManager(); locationManager.Delegate = new LocationManagerDelegate(mapView, this); locationManager.StartUpdatingLocation(); // Add the table view as a subview View.AddSubview(mapView); View.AddSubview(labelDistance); View.AddSubview(segmentedControl); // Add the 'info' button to flip var flipButton = UIButton.FromType(UIButtonType.InfoLight); flipButton.Frame = new RectangleF(290,17,20,20); flipButton.Title (UIControlState.Normal); flipButton.TouchDown += delegate { _mfvc.Flip(); }; View.AddSubview(flipButton); }
public override void ViewDidLoad() { base.ViewDidLoad (); mapView = new MKMapView() { ShowsUserLocation = true }; labelDistance = new UILabel() { Frame = new RectangleF (0, 0, 320, 49), Lines = 2, BackgroundColor = UIColor.Black, TextColor = UIColor.White }; var segmentedControl = new UISegmentedControl(); var topOfSegement = View.Frame.Height - 120; segmentedControl.Frame = new RectangleF(20, topOfSegement, 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; if(UIDevice.CurrentDevice.CheckSystemVersion(6,0)) segmentedControl.InsertSegment ("Directions", 3, false); 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; else if (segmentedControl.SelectedSegment == 3) { var conferenceMapItem = new MKMapItem(new MKPlacemark(ConferenceLocation, null)); conferenceMapItem.Name = "MonkeySpace"; var conferenceHotel = new MKMapItem(new MKPlacemark(new CLLocationCoordinate2D(42.36346, -71.0863), null)); conferenceHotel.Name = "MonkeySpace Hotel"; var mapItems = new MKMapItem[] { conferenceMapItem, conferenceHotel }; MKMapItem.OpenMaps(mapItems, new MKLaunchOptions() { DirectionsMode = MKDirectionsMode.Walking }); } }; mapView.Delegate = new MapViewDelegate(this); // Set the web view to fit the width of the app. mapView.SizeToFit(); // Reposition and resize the receiver mapView.Frame = new RectangleF (0, 50, View.Frame.Width, View.Frame.Height - 100); MKCoordinateSpan span = new MKCoordinateSpan(0.01,0.01); MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation,span); mapView.SetRegion(region, true); ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation , "MonkeySpace" , "NERD Center" ); mapView.AddAnnotationObject(a); locationManager = new CLLocationManager(); locationManager.Delegate = new LocationManagerDelegate(mapView, this); locationManager.StartUpdatingLocation(); // Add the table view as a subview View.AddSubview(mapView); View.AddSubview(labelDistance); View.AddSubview(segmentedControl); // Add the 'info' button to flip var flipButton = UIButton.FromType(UIButtonType.InfoLight); flipButton.Frame = new RectangleF(290,17,20,20); flipButton.Title (UIControlState.Normal); flipButton.TouchDown += delegate { _mfvc.Flip(); }; View.AddSubview(flipButton); }
public override void ViewDidLoad() { base.ViewDidLoad(); navBar = new UINavigationBar(new RectangleF(0, 0, 320, 44)); var bbi = new UIBarButtonItem(UIImage.FromBundle("Images/slideout"), UIBarButtonItemStyle.Plain, (sender, e) => { AppDelegate.Current.FlyoutNavigation.ToggleMenu(); }); var rbi = new UIBarButtonItem(UIImage.FromBundle("Images/113-navigation"), UIBarButtonItemStyle.Plain, (sender, e) => { mapFlipViewController.Flip(); }); var item = new UINavigationItem("Location Map"); item.LeftBarButtonItem = bbi; item.RightBarButtonItem = rbi; var items = new UINavigationItem[] { item }; navBar.SetItems(items, false); mapView = new MKMapView() { ShowsUserLocation = true }; labelDistance = new UILabel() { Frame = new RectangleF(0, 44, 320, 49), Lines = 2, BackgroundColor = UIColor.Black, TextColor = UIColor.White }; var segmentedControl = new UISegmentedControl(); var topOfSegement = View.Frame.Height - 60; segmentedControl.Frame = new RectangleF(20, topOfSegement, 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); // Set the web view to fit the width of the app. mapView.SizeToFit(); // Reposition and resize the receiver mapView.Frame = new RectangleF(0, 44 + 50, View.Frame.Width, View.Frame.Height - 93); MKCoordinateSpan span = new MKCoordinateSpan(0.01, 0.01); MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation.Location.To2D(), span); mapView.SetRegion(region, true); ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation.Location.To2D() , ConferenceLocation.Title , ConferenceLocation.Subtitle ); mapView.AddAnnotationObject(a); locationManager = new CLLocationManager(); locationManager.Delegate = new LocationManagerDelegate(mapView, this); locationManager.Purpose = "Show distance on map"; // also Info.plist locationManager.StartUpdatingLocation(); // Add the table view as a subview View.AddSubview(mapView); View.AddSubview(labelDistance); View.AddSubview(segmentedControl); // Add the 'info' button to flip var flipButton = UIButton.FromType(UIButtonType.InfoLight); flipButton.Frame = new RectangleF(290, 17, 20, 20); flipButton.Title(UIControlState.Normal); flipButton.TouchDown += delegate { mapFlipViewController.Flip(); }; View.AddSubview(flipButton); View.Add(navBar); }
public override void ViewDidLoad() { base.ViewDidLoad(); // no XIB ! mapView = new MKMapView() { ShowsUserLocation = true }; labelDistance = new UILabel() { Frame = new RectangleF(0, 0, 320, 49), Lines = 2, BackgroundColor = UIColor.Black, TextColor = UIColor.White }; var segmentedControl = new UISegmentedControl(); segmentedControl.Frame = new RectangleF(20, 320, 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); // 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 - 100); MKCoordinateSpan span = new MKCoordinateSpan(0.2, 0.2); MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation, span); mapView.SetRegion(region, true); ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation , conf.Location.Title , conf.Location.Subtitle ); 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 var flipButton = UIButton.FromType(UIButtonType.InfoLight); flipButton.Frame = new RectangleF(290, 17, 20, 20); flipButton.Title(UIControlState.Normal); flipButton.TouchDown += delegate { _mfvc.Flip(); }; 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 }; // Black looks good! this.View.BackgroundColor = UIColor.Black; 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(MyLocation, span); mapView.SetRegion(region, true); MyAnnotation a = new MyAnnotation(MyLocation , "Hero's Sports Bar" , "2855 N Power Rd, Mesa, Arizona" ); 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); }
private void showMapa(bool doanimation) { double zoom = 5f; double latMain = Convert.ToDouble(dataPos.lat); double lonMain = Convert.ToDouble(dataPos.lon); List <MyAnnotation> pins = null; try { //Console.WriteLine ("Entra carga mapa"); if (map != null) { hideMapa(false); } map = new MKMapView();// (new RectangleF (0, 0, 400f, 300f )); map.Frame = this.View.Bounds; map.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; //?? map.Region = new MonoTouch.MapKit.MKCoordinateRegion(new CLLocationCoordinate2D(latMain, lonMain), new MKCoordinateSpan(zoom, zoom)); vmap = new UIView(new RectangleF(0, 0, this.View.Bounds.Width, this.View.Bounds.Height)); vmap.AutosizesSubviews = true; vmap.BackgroundColor = UIColor.FromRGBA(0.0f, 0.0f, 0.0f, 0.75f); vmap.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; vmap.AddSubview(map); View.AddSubview(vmap); //this.View.AddSubview (v); double lat = latMain; double lon = lonMain; if (pins == null) { pins = new List <MyAnnotation> (); } pins.Add(new MyAnnotation(new CLLocationCoordinate2D(lat, lon), "hotel.Name", "hotel.Adress", MKPinAnnotationColor.Purple, null)); map.MapType = MonoTouch.MapKit.MKMapType.Standard; map.Region = new MKCoordinateRegion(new CLLocationCoordinate2D(latMain, lonMain), new MKCoordinateSpan(zoom, zoom)); } catch (Exception ex) { Console.WriteLine("Error en la carga de Mapas. Error: " + ex.Message); } //var logo = UIImage.FromBundle ("images/googlemaps-point"); map.GetViewForAnnotation = delegate(MKMapView mapView, NSObject annotation) { // Called by the map whenever an annotation is added and needs to be displayed if (annotation is MKUserLocation) { return(null); } MyAnnotation myAnn = annotation as MyAnnotation; var annView = mapView.DequeueReusableAnnotation("mypin"); if (annView == null) { var pinView = new MKPinAnnotationView(myAnn, "mypin"); pinView.AnimatesDrop = true; //pinView.Image = UIImage.FromBundle ("images/googlemaps-point"); //UIImageView imgView = new UIImageView (logo); //imgView.Frame = new System.Drawing.RectangleF (-8, -5, 32, 39); //pinView.AddSubview (imgView);// .PinColor = myAnn.Color; pinView.PinColor = MKPinAnnotationColor.Purple;// .PinColor = myAnn.Color; //pinView.AutosizesSubviews =true; // pinView.Image = UIImage.FromFile ("images/googlemaps-point.png"); pinView.CanShowCallout = false; //pinView.LeftCalloutAccessoryView = imgView ; UIButton rightCallout = UIButton.FromType(UIButtonType.DetailDisclosure); rightCallout.TouchUpInside += delegate { //pinView.AddSubview(imgView);// .PinColor = myAnn.Color; }; myAnn.app = this; //myAnn.list =list; // myAnn.HotelSearch = HotelSearch ; if (myAnn.active) { pinView.RightCalloutAccessoryView = myAnn.btnSelect;// rightCallout; } annView = pinView; } else { annView.Annotation = annotation; } return(annView); }; map.ZoomEnabled = true; map.ScrollEnabled = true; map.UserInteractionEnabled = true; map.ShowsUserLocation = false; // shows the "blue dot" user location (if available) //map.UserLocation.Title = Language.GetString ("BEM00125"); //map.UserLocation.Subtitle = Language.GetString ("BEM00126"); map.DidFailToLocateUser += delegate(object sender, NSErrorEventArgs e) { }; map.LoadingMapFailed += delegate(object sender, NSErrorEventArgs e) { //Tools.ShowAlert("TODO: Lo sentimos el mapa no puede ser cargado en este momento"); }; foreach (MyAnnotation hot in pins) { if (hot.Coordinate.IsValid()) { map.AddAnnotationObject(hot); } } map.CenterCoordinate = new CLLocationCoordinate2D(latMain, lonMain); map.Region = new MKCoordinateRegion(new CLLocationCoordinate2D(latMain, lonMain), new MKCoordinateSpan(.1, .1)); map.ShowsUserLocation = true; // shows the "blue dot" user location (if available) }
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 }; // Black looks good! this.View.BackgroundColor = UIColor.Black; 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(MyLocation,span); mapView.SetRegion(region, true); MyAnnotation a = new MyAnnotation(MyLocation , "Hero's Sports Bar" , "2855 N Power Rd, Mesa, Arizona" ); 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 (); navBar = new UINavigationBar (new RectangleF (0, 0, 320, 44)); var bbi = new UIBarButtonItem(UIImage.FromBundle ("Images/slideout"), UIBarButtonItemStyle.Plain, (sender, e) => { AppDelegate.Current.FlyoutNavigation.ToggleMenu(); }); var rbi = new UIBarButtonItem (UIImage.FromBundle ("Images/113-navigation"), UIBarButtonItemStyle.Plain, (sender,e) => { mapFlipViewController.Flip(); }); var item = new UINavigationItem ("Location Map"); item.LeftBarButtonItem = bbi; item.RightBarButtonItem = rbi; var items = new UINavigationItem[] { item }; navBar.SetItems (items, false); mapView = new MKMapView() { ShowsUserLocation = true }; labelDistance = new UILabel() { Frame = new RectangleF (0, 44, 320, 49), Lines = 2, BackgroundColor = UIColor.Black, TextColor = UIColor.White }; var segmentedControl = new UISegmentedControl(); var topOfSegement = View.Frame.Height - 60; segmentedControl.Frame = new RectangleF(20, topOfSegement, 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); // Set the web view to fit the width of the app. mapView.SizeToFit(); // Reposition and resize the receiver mapView.Frame = new RectangleF (0, 44 + 50, View.Frame.Width, View.Frame.Height - 93); MKCoordinateSpan span = new MKCoordinateSpan(0.01,0.01); MKCoordinateRegion region = new MKCoordinateRegion(ConferenceLocation.Location.To2D(),span); mapView.SetRegion(region, true); ConferenceAnnotation a = new ConferenceAnnotation(ConferenceLocation.Location.To2D() , ConferenceLocation.Title , ConferenceLocation.Subtitle ); mapView.AddAnnotationObject(a); locationManager = new CLLocationManager(); locationManager.Delegate = new LocationManagerDelegate(mapView, this); locationManager.Purpose = "Show distance on map"; // also Info.plist locationManager.StartUpdatingLocation(); // Add the table view as a subview View.AddSubview(mapView); View.AddSubview(labelDistance); View.AddSubview(segmentedControl); // Add the 'info' button to flip var flipButton = UIButton.FromType(UIButtonType.InfoLight); flipButton.Frame = new RectangleF(290,17,20,20); flipButton.Title (UIControlState.Normal); flipButton.TouchDown += delegate { mapFlipViewController.Flip(); }; View.AddSubview(flipButton); View.Add (navBar); }