public void SetLocation(MonkeySpace.Core.MapLocation toLocation) { var targetLocation = toLocation.Location.To2D(); if (toLocation.Location.X == 0 && toLocation.Location.Y == 0) { // use the 'location manager' current coordinate if (locationManager.Location == null) { return; // catch a possible null reference that i saw once [CD] } else { targetLocation = locationManager.Location.Coordinate; ConferenceAnnotation a = new ConferenceAnnotation(targetLocation, "My location", ""); mapView.AddAnnotationObject(a); } } else if (toLocation.Title == "MonkeySpace") { // no need to drop anything } else { // drop a new pin ConferenceAnnotation a = new ConferenceAnnotation(toLocation.Location.To2D(), toLocation.Title, toLocation.Subtitle); mapView.AddAnnotationObject(a); } mapView.CenterCoordinate = targetLocation; }
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 void SetLocation(MonkeySpace.Core.MapLocation toLocation) { var targetLocation = toLocation.Location.To2D(); if (toLocation.Location.X == 0 && toLocation.Location.Y == 0) { // use the 'location manager' current coordinate if (locationManager.Location == null) { return; } { // catch a possible null reference that i saw once [CD] targetLocation = locationManager.Location.Coordinate; ConferenceAnnotation a = new ConferenceAnnotation(targetLocation, "My location".GetText(), ""); mapView.AddAnnotationObject(a); } } else if (toLocation.Title == "MonkeySpace") { // no need to drop anything } else { // drop a new pin ConferenceAnnotation a = new ConferenceAnnotation(toLocation.Location.To2D(), toLocation.Title,toLocation.Subtitle); mapView.AddAnnotationObject(a); } mapView.CenterCoordinate = targetLocation; }
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(); 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; 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 , "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); }