public void GetLocation(GetLocationActions locActions, UITextField textField) { if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { UpdateLocation(e.Locations [e.Locations.Length - 1], iPhoneLocationManager, locActions, textField); }; } else { // this won't be called on iOS 6 (deprecated) iPhoneLocationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => { UpdateLocation(e.NewLocation, iPhoneLocationManager, locActions, textField); }; } // handle the updated heading method and update the UI iPhoneLocationManager.UpdatedHeading += (object sender, CLHeadingUpdatedEventArgs e) => { Console.WriteLine(e.NewHeading.MagneticHeading.ToString() + "º"); Console.WriteLine(e.NewHeading.TrueHeading.ToString() + "º"); }; // start updating our location, et. al. if (CLLocationManager.LocationServicesEnabled) { iPhoneLocationManager.StartUpdatingLocation(); } if (CLLocationManager.HeadingAvailable) { iPhoneLocationManager.StartUpdatingHeading(); } }
public void GetLocation (GetLocationActions locActions, UITextField textField) { if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) { iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { UpdateLocation (e.Locations [e.Locations.Length - 1], iPhoneLocationManager, locActions, textField); }; } else { // this won't be called on iOS 6 (deprecated) iPhoneLocationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => { UpdateLocation (e.NewLocation, iPhoneLocationManager, locActions, textField); }; } // handle the updated heading method and update the UI iPhoneLocationManager.UpdatedHeading += (object sender, CLHeadingUpdatedEventArgs e) => { Console.WriteLine(e.NewHeading.MagneticHeading.ToString () + "º"); Console.WriteLine(e.NewHeading.TrueHeading.ToString () + "º"); }; // start updating our location, et. al. if (CLLocationManager.LocationServicesEnabled) iPhoneLocationManager.StartUpdatingLocation (); if (CLLocationManager.HeadingAvailable) iPhoneLocationManager.StartUpdatingHeading (); }
static public void UpdateLocation (CLLocation newLocation, CLLocationManager locManager, GetLocationActions locActions, UITextField textField) { Console.WriteLine(newLocation.Coordinate.Longitude.ToString () + "º"); Console.WriteLine(newLocation.Coordinate.Latitude.ToString () + "º"); //FireEvent OnLocationChanged (textField, locActions, newLocation.Coordinate.Latitude.ToString (), newLocation.Coordinate.Longitude.ToString ()); if (CLLocationManager.LocationServicesEnabled) locManager.StopUpdatingLocation (); if (CLLocationManager.HeadingAvailable) locManager.StopUpdatingHeading (); }
static public void UpdateLocation(CLLocation newLocation, CLLocationManager locManager, GetLocationActions locActions, UITextField textField) { Console.WriteLine(newLocation.Coordinate.Longitude.ToString() + "º"); Console.WriteLine(newLocation.Coordinate.Latitude.ToString() + "º"); //FireEvent OnLocationChanged(textField, locActions, newLocation.Coordinate.Latitude.ToString(), newLocation.Coordinate.Longitude.ToString()); if (CLLocationManager.LocationServicesEnabled) { locManager.StopUpdatingLocation(); } if (CLLocationManager.HeadingAvailable) { locManager.StopUpdatingHeading(); } }
UIView CreateTextView(UITextField textField, string placeholderText, string text, RectangleF rectF, GetLocationActions locActions) { UIView uiView = new UIView(rectF); uiView.MultipleTouchEnabled = true; textField.Frame = new RectangleF(20, 0, this.View.Bounds.Width - 110, 30); textField.Font = font12; textField.Placeholder = placeholderText; textField.Text = text; textField.BorderStyle = UITextBorderStyle.RoundedRect; textField.Enabled = true; uiView.AddSubview(textField); GlassButton gbLoc = new GlassButton(new RectangleF(textField.Bounds.Width + 20 + 5, 0, 80, 30)); if (locActions != GetLocationActions.None) { gbLoc.Font = font10; gbLoc.NormalColor = UIColor.Brown; gbLoc.SetTitle("Use Location", UIControlState.Normal); gbLoc.Enabled = true; gbLoc.Tapped += delegate { textField.Enabled = false; if (locActions == GetLocationActions.UpdateTraffic) { gbBlocked.Enabled = false; gbHeavy.Enabled = false; gbNormal.Enabled = false; gbLow.Enabled = false; } else if (locActions == GetLocationActions.SetOrigin) { gbViewTraffic.Enabled = false; } else if (locActions == GetLocationActions.SetDestination) { gbViewTraffic.Enabled = false; } GetLocation(locActions, textField); }; uiView.AddSubview(gbLoc); } return(uiView); }
UIView CreateTextView(UITextField textField, string placeholderText, string text, RectangleF rectF, GetLocationActions locActions){ UIView uiView = new UIView (rectF); uiView.MultipleTouchEnabled = true; textField.Frame = new RectangleF (20, 0, this.View.Bounds.Width-110, 30); textField.Font = font12; textField.Placeholder = placeholderText; textField.Text = text; textField.BorderStyle = UITextBorderStyle.RoundedRect; textField.Enabled = true; uiView.AddSubview (textField); GlassButton gbLoc = new GlassButton (new RectangleF (textField.Bounds.Width + 20 + 5, 0, 80, 30)); if (locActions != GetLocationActions.None) { gbLoc.Font = font10; gbLoc.NormalColor = UIColor.Brown; gbLoc.SetTitle ("Use Location", UIControlState.Normal); gbLoc.Enabled = true; gbLoc.Tapped += delegate { textField.Enabled = false; if (locActions == GetLocationActions.UpdateTraffic) { gbBlocked.Enabled = false; gbHeavy.Enabled = false; gbNormal.Enabled = false; gbLow.Enabled = false; } else if (locActions == GetLocationActions.SetOrigin) { gbViewTraffic.Enabled = false; } else if (locActions == GetLocationActions.SetDestination) { gbViewTraffic.Enabled = false; } GetLocation (locActions, textField); }; uiView.AddSubview (gbLoc); } return uiView; }