public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. ConfigureView(); _iPhoneLocationManager = new CLLocationManager(); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { _iPhoneLocationManager.RequestWhenInUseAuthorization(); } mapView.ShowsUserLocation = true; if (mapView.UserLocationVisible) { UpdateUiCoords(); } _iPhoneLocationManager.DesiredAccuracy = 1000; // 1000 meters/1 kilometer mapView.DidUpdateUserLocation += (sender, e) => { if (mapView.UserLocation != null) { CLLocationCoordinate2D coords = mapView.UserLocation.Coordinate; MKCoordinateSpan span = new MKCoordinateSpan(MilesToLatitudeDegrees(2), MilesToLongitudeDegrees(2, coords.Latitude)); mapView.Region = new MKCoordinateRegion(coords, span); UpdateUiCoords(); } }; }
public TCLocationManager () { locationManager = new CLLocationManager (); locationManager.DistanceFilter = 10; locationManager.Delegate = new TCLocationDelegate (); }
public void StartTimer(CLLocationManager manager) { hasLastAttempt = false; Manager = manager; locationTimer = NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(30), TerminateLocationUpdate); }
public GPSTracker() { if (CLLocationManager.LocationServicesEnabled) { _manager = new CLLocationManager(); } }
public void Init(Action<PLVPaylevenStatus> action, string currency) { locationManager = new CLLocationManager(); // TODO: Get current location paylevenManager = new PaylevenManager(action, currency, 52.252505, 21.023012); }
public override void FinishedLaunching(UIApplication application) { locationManager = new CLLocationManager (); if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) { locationManager.RequestWhenInUseAuthorization (); } // A user can transition in or out of a region while the application is not running. // When this happens CoreLocation will launch the application momentarily, call this delegate method // and we will let the user know via a local notification. locationManager.DidDetermineState += (sender, e) => { string body = null; if (e.State == CLRegionState.Inside) body = "You're inside the region"; else if (e.State == CLRegionState.Outside) body = "You're outside the region"; if (body != null) { var notification = new UILocalNotification () { AlertBody = body }; // If the application is in the foreground, it will get called back to ReceivedLocalNotification // If its not, iOS will display the notification to the user. UIApplication.SharedApplication.PresentLocalNotificationNow (notification); } }; }
public void Start () { if (CLLocationManager.LocationServicesEnabled) { lman = new CLLocationManager { DesiredAccuracy = CLLocation.AccuracyBest, }; lman.RequestWhenInUseAuthorization (); lman.LocationsUpdated += (sender, e) => { var loc = e.Locations [0]; Timestamp = loc.Timestamp; Location = new Location (loc.Coordinate.Latitude, loc.Coordinate.Longitude, loc.Altitude); // Console.WriteLine (Location); HorizontalAccuracy = loc.HorizontalAccuracy; VerticalAccuracy = loc.VerticalAccuracy; LocationReceived (this, EventArgs.Empty); }; lman.UpdatedHeading += (sender, e) => { Heading = e.NewHeading.TrueHeading; // Console.WriteLine ("Heading: {0}", Heading); }; lman.StartUpdatingLocation (); lman.StartUpdatingHeading (); } }
public override void ViewDidLoad() { base.ViewDidLoad (); locMan = new CLLocationManager(); locMan.RequestWhenInUseAuthorization(); locMan.RequestAlwaysAuthorization(); // Geocode a city to get a CLCircularRegion, // and then use our location manager to set up a geofence button.TouchUpInside += (o, e) => { // clean up monitoring of old region so they don't pile up if(region != null) { locMan.StopMonitoring(region); } // Geocode city location to create a CLCircularRegion - what we need for geofencing! var taskCoding = geocoder.GeocodeAddressAsync ("Cupertino"); taskCoding.ContinueWith ((addresses) => { CLPlacemark placemark = addresses.Result [0]; region = (CLCircularRegion)placemark.Region; locMan.StartMonitoring(region); }); }; // This gets called even when the app is in the background - try it! locMan.RegionEntered += (sender, e) => { Console.WriteLine("You've entered the region"); }; locMan.RegionLeft += (sender, e) => { Console.WriteLine("You've left the region"); }; }
public void LocationManagerDidUpdateToLocationFromLocation(CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation) { // Ignore updates where nothing we care about changed if (oldLocation != null && newLocation.Coordinate.longitude == oldLocation.Coordinate.longitude && newLocation.Coordinate.latitude == oldLocation.Coordinate.latitude && newLocation.HorizontalAccuracy == oldLocation.HorizontalAccuracy) { return; } // Load the HTML for displaying the Google map from a file and replace the // format placeholders with our location data NSError error; NSString htmlString = NSString.StringWithFormat( NSString.StringWithContentsOfFileEncodingError( NSBundle.MainBundle.PathForResourceOfType("HTMLFormatString", @"html"), NSStringEncoding.NSUTF8StringEncoding,out error), newLocation.Coordinate.latitude, newLocation.Coordinate.longitude, LatitudeRangeForLocation(newLocation), LongitudeRangeForLocation(newLocation)); // Load the HTML in the WebView and set the labels this.webView.MainFrame.LoadHTMLStringBaseURL(htmlString, null); this.locationLabel.StringValue = NSString.StringWithFormat("%f, %f", newLocation.Coordinate.latitude, newLocation.Coordinate.longitude); this.accuracyLabel.StringValue = NSString.StringWithFormat("%f", newLocation.HorizontalAccuracy); }
public override void ViewDidLoad () { base.ViewDidLoad (); locationManager = new CLLocationManager (); locationManager.AuthorizationChanged += OnAuthorizationChanged; locationManager.LocationsUpdated += OnLocationsUpdated; locationManager.DesiredAccuracy = CLLocation.AccuracyBest; locationManager.ActivityType = CLActivityType.Other; // We setup a pair of anchors that will define how the floorplan image, maps to geographic co-ordinates var anchor1 = new GeoAnchor { LatitudeLongitude = new CLLocationCoordinate2D (37.770511, -122.465810), Pixel = new CGPoint (12, 18) }; var anchor2 = new GeoAnchor { LatitudeLongitude = new CLLocationCoordinate2D (37.769125, -122.466356), Pixel = new CGPoint (481, 815) }; anchorPair = new Tuple<GeoAnchor, GeoAnchor> (anchor1, anchor2); // Initialize the coordinate system converter with two anchor points. coordinateConverter = new CoordinateConverter (anchorPair); }
public override void LocationsUpdated(CLLocationManager manager, CLLocation[] locations) { Task.Run (async () => {await AppDelegate.FlicService.RefreshPendingConnections();}); foreach(var loc in locations) { Console.WriteLine(loc); } }
public LocationTestService() { locationManager = new CLLocationManager(); locationManager.LocationsUpdated += LocationsUpdated; locationManager.DistanceFilter = 10; locationManager.DesiredAccuracy = CLLocation.AccuracyBest; }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { global::Xamarin.Forms.Forms.Init(); global::Xamarin.FormsMaps.Init(); locationManager = new CLLocationManager { DesiredAccuracy = CLLocation.AccuracyBest }; locationManager.Failed += (object sender, NSErrorEventArgs e) => { var alert = new UIAlertView(){ Title = "Location manager failed", Message = "The location updater has failed" }; alert.Show(); locationManager.StopUpdatingLocation(); }; locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { var newloc = string.Format("{0},{1}", e.Locations[0].Coordinate.Longitude, e.Locations[0].Coordinate.Latitude); App.Self.ChangedClass.BroadcastIt("location", newloc); }; locationManager.StartUpdatingLocation(); LoadApplication(new App()); return base.FinishedLaunching(app, options); }
public override void UpdatedLocation (CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation) { _helper.Locations.Add (newLocation); if (_helper.LocationAdded != null) _helper.LocationAdded (_helper, new LocationEventArgs (newLocation)); }
public override void ViewDidLoad() { base.ViewDidLoad (); manager = new CLLocationManager (); // handle the updated location method and update the UI if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) { manager.LocationsUpdated += LocationsUpdated; } else { // this won't be called on iOS 6 (deprecated) manager.UpdatedLocation += UpdatedLocation; } if (CLLocationManager.LocationServicesEnabled) manager.StartUpdatingLocation (); //if (CLLocationManager.HeadingAvailable) // manager.StartUpdatingHeading (); mapView.GetViewForAnnotation += GetAirportAnnotationView; mapView.RegionChanged += MapRegionChanged; mapType.ValueChanged += MapTypeChanged; MapTypeChanged (null, null); }
public GeolocationSingleUpdateDelegate(CLLocationManager manager, double desiredAccuracy, bool includeHeading, int timeout, CancellationToken cancelToken) { this.manager = manager; this.tcs = new TaskCompletionSource<Position>(manager); this.desiredAccuracy = desiredAccuracy; this.includeHeading = includeHeading; if (timeout != Timeout.Infinite) { Timer t = null; t = new Timer(s => { if (this.haveLocation) this.tcs.TrySetResult(new Position(this.position)); else this.tcs.TrySetCanceled(); StopListening(); t.Dispose(); }, null, timeout, 0); } cancelToken.Register(() => { StopListening(); this.tcs.TrySetCanceled(); }); }
public override void ViewDidLoad() { base.ViewDidLoad (); int speedSystem = 0; kmhourButton.ValueChanged += (sender,e) => { speedSystem = kmhourButton.SelectedSegment; }; _iPhoneLocationManager = new CLLocationManager (); _iPhoneLocationManager.DesiredAccuracy = 1000; // 1000 meters/1 kilometer //update location based on the specified metric system _iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { UpdateLocation (speedSystem, e.Locations [e.Locations.Length - 1].Speed); }; if (CLLocationManager.LocationServicesEnabled) _iPhoneLocationManager.StartUpdatingLocation (); //if viewmap button is touched then display the map ViewMap.TouchUpInside += (object sender, EventArgs e) => { if (_speedController == null) _speedController = new SpeedController(); //_speedController = new MapController(); NavigationController.PushViewController(_speedController, true); }; }
public override bool FinishedLaunching (UIApplication app, NSDictionary options) { window = new UIWindow (UIScreen.MainScreen.Bounds); var what = new EntryElement ("What ?", "e.g. pizza", String.Empty); var where = new EntryElement ("Where ?", "here", String.Empty); var section = new Section (); if (CLLocationManager.LocationServicesEnabled) { lm = new CLLocationManager (); lm.LocationsUpdated += delegate (object sender, CLLocationsUpdatedEventArgs e) { lm.StopUpdatingLocation (); here = e.Locations [e.Locations.Length - 1]; var coord = here.Coordinate; where.Value = String.Format ("{0:F4}, {1:F4}", coord.Longitude, coord.Latitude); }; section.Add (new StringElement ("Get Current Location", delegate { lm.StartUpdatingLocation (); })); } section.Add (new StringElement ("Search...", async delegate { await SearchAsync (what.Value, where.Value); })); var root = new RootElement ("MapKit Search Sample") { new Section ("MapKit Search Sample") { what, where }, section }; window.RootViewController = new UINavigationController (new DialogViewController (root, true)); window.MakeKeyAndVisible (); return true; }
/// <summary> /// get the location of user and update to server /// </summary> public static void DoLocationAndUpdated() { Location.iPhoneLocationManager = new CLLocationManager (); Location.iPhoneLocationManager.DesiredAccuracy = 5; // 1000 meters/1 kilometer // if this is iOs6 if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) { Location.iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { CLLocation newLocation = e.Locations [e.Locations.Length - 1]; Utils.Log("ios6"); Location.UpdateLocationToServer(newLocation.Coordinate.Latitude.ToString (), newLocation.Coordinate.Longitude.ToString ()); //iPhoneLocationManager.StopUpdatingLocation(); }; } // if it is iOs 5 or lower else { Location.iPhoneLocationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => { CLLocation newLocation = e.NewLocation; Utils.Log("ios5"); Location.UpdateLocationToServer(newLocation.Coordinate.Latitude.ToString (), newLocation.Coordinate.Longitude.ToString ()); //iPhoneLocationManager.StopUpdatingLocation(); }; } if (CLLocationManager.LocationServicesEnabled) iPhoneLocationManager.StartUpdatingLocation (); }
public GPSProvider () { if (CLLocationManager.LocationServicesEnabled) { _manager = new CLLocationManager (); _manager.DesiredAccuracy = CLLocation.AccurracyBestForNavigation; _manager.Delegate = new LocationManagerDelegate (this); } }
public MonitoringViewController (IntPtr handle) : base (handle) { locationManger = new CLLocationManager (); numberFormatter = new NSNumberFormatter () { NumberStyle = NSNumberFormatterStyle.Decimal }; uuid = Defaults.DefaultProximityUuid; }
void DidRangeBeacons(object sender, CLLocationManager.DidRangeBeaconsEventArgs e) { if (e.beacons.Length == 0) return; CLBeacon beacon = e.beacons[0] as CLBeacon; Log("distance: " + beacon.proximity); }
public void ServiceConnected() { locationMgr = new CLLocationManager(); locationMgr.DidRangeBeacons += locationMgr_DidRangeBeacons; locationMgr.RegionEntered += locationMgr_RegionEntered; locationMgr.RegionLeft += locationMgr_RegionLeft; }
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { // If user has services disabled, we're just going to throw an exception for consistency. if (status == CLAuthorizationStatus.Denied || status == CLAuthorizationStatus.Restricted) { StopListening(); this.tcs.TrySetException(new GeolocationException(GeolocationError.Unauthorized)); } }
void DidEnterRegion(object sender, CLLocationManager.DidEnterEventArgs e) { UnityEngine.iOS.LocalNotification notif = new UnityEngine.iOS.LocalNotification(); notif.alertBody = "Found beacon!"; UnityEngine.iOS.NotificationServices.PresentLocalNotificationNow(notif); Log("Found beacon."); locationManager.StartRangingBeaconsInRegion(beaconRegion); }
LocationHelper() { Locations = new List<CLLocation> (); manager = new CLLocationManager (); manager.DesiredAccuracy = CLLocation.AccuracyBest; manager.DistanceFilter = CLLocation.AccuracyBest; manager.Delegate = new LocationDelegate (this); }
void DidExitRegion(object sender, CLLocationManager.DidExitEventArgs e) { UnityEngine.iOS.LocalNotification notif = new UnityEngine.iOS.LocalNotification(); notif.alertBody = "Lost beacon!"; UnityEngine.iOS.NotificationServices.PresentLocalNotificationNow(notif); Log("Left region."); locationManager.StopRangingBeaconsInRegion(beaconRegion); }
public override void Failed (CLLocationManager manager, NSError error) { if (error.Code == (int)CLError.Denied) { Console.WriteLine ("Access to location services denied"); manager.StopUpdatingLocation (); manager.Delegate = null; } }
public override void UpdatedLocation (CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation) { Console.WriteLine ("New location data = {0}", newLocation.Description ()); _helper.Locations.Add (newLocation); if (_helper.LocationAdded != null) _helper.LocationAdded (_helper, new EventArgs ()); }
public void EnableLocationServices() { manager = new CLLocationManager(); manager.AuthorizationChanged += (sender, args) => { Console.WriteLine ("Authorization changed to: {0}", args.Status); }; if (UIDevice.CurrentDevice.CheckSystemVersion(8,0)) manager.RequestWhenInUseAuthorization(); }
public override void DidStartMonitoringForRegion(CLLocationManager manager, CLRegion region) { }
public override void DidDetermineState(CLLocationManager manager, CLRegionState state, CLRegion region) { }
public override void Failed(CLLocationManager manager, NSError error) { // ignored for now }
public GeofenceManagerImpl() { this.locationManager = new CLLocationManager(); this.locationManager.RegionEntered += (sender, args) => this.DoBroadcast(args, GeofenceStatus.Entered); this.locationManager.RegionLeft += (sender, args) => this.DoBroadcast(args, GeofenceStatus.Exited); }
public override void ViewWillAppear(bool animated) { base.ViewWillAppear(animated); //Ocultamos el campo de observaciones, ya que por lo visto no se almacena en ningun lado, esperamos respuesta this.cmpObservaciones.Hidden = true; this.lblObservaciones.Hidden = true; //Ocultamos los labels donde se muestran las coordenadas del dispositivo this.lblLatitud.Hidden = true; this.lblLongitud.Hidden = true; //Declarar el Location Manager iPhoneLocationManager = new CLLocationManager(); iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters; //Obtener la posicion del dispositivo //El metodo es diferente en iOS 6 se verifica la version del S.O. if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { UpdateLocation(e.Locations [e.Locations.Length - 1]); }; } else { iPhoneLocationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => { UpdateLocation(e.NewLocation); }; } iPhoneLocationManager.UpdatedHeading += (object sender, CLHeadingUpdatedEventArgs e) => { }; //Actualizar la ubicacion if (CLLocationManager.LocationServicesEnabled) { iPhoneLocationManager.StartUpdatingLocation(); } if (CLLocationManager.HeadingAvailable) { iPhoneLocationManager.StartUpdatingHeading(); } //Se esconde el booton para ir a la vista anterior this.NavigationItem.HidesBackButton = true; //se crea el boton para regresar a la vista anterior, verificando que la tarea haya sido dada de alta UIBarButtonItem regresar = new UIBarButtonItem(); regresar.Style = UIBarButtonItemStyle.Plain; regresar.Target = this; regresar.Title = "Lista de tareas"; regresar.Clicked += (sender, e) => { if (this.listo == false) { UIAlertView alert = new UIAlertView() { Title = "¿Salir?", Message = "Si sales se perderá el registro de la tarea" }; alert.AddButton("Aceptar"); alert.AddButton("Cancelar"); alert.Clicked += (s, o) => { if (o.ButtonIndex == 0) { NavigationController.PopViewControllerAnimated(true); } }; alert.Show(); } else { NavigationController.PopViewControllerAnimated(true); } }; //posionamiento del boton this.NavigationItem.LeftBarButtonItem = regresar; //Se establece un borde para el textarea de la descripcion this.cmpDescripcion.Layer.BorderWidth = 1.0f; this.cmpDescripcion.Layer.BorderColor = UIColor.Gray.CGColor; this.cmpDescripcion.Layer.ShadowColor = UIColor.Black.CGColor; this.cmpDescripcion.Layer.CornerRadius = 8; //Declaramos el datamodel para los responsables pickerDataModelResponsibles = new PickerDataModelResponsibles(); //Declaramos el datamodel para las categorias pickerDataModelCategories = new PickerDataModelCategories(); //Declaramos el datamodel para el picker de prioridades pickerDataModel = new PickerDataModel(); //Declaramos el datamodel para el picker de buisqueda de personas pickerDataModelPeople = new PickerDataModelPeople(); //Declaramos el actionsheet donde se mostrara el picker actionSheetPicker = new ActionSheetPicker(this.View); this.btnResponsable.TouchUpInside += (sender, e) => { try{ responsibleService = new ResponsibleService(); pickerDataModelResponsibles.Items = responsibleService.All(); actionSheetPicker.Picker.Source = pickerDataModelResponsibles; actionSheetPicker.Show(); }catch (System.Net.WebException) { UIAlertView alert = new UIAlertView() { Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet" }; alert.AddButton("Aceptar"); alert.Show(); } catch (System.Exception) { UIAlertView alert = new UIAlertView() { Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo" }; alert.AddButton("Aceptar"); alert.Show(); } }; this.btnCategoria.TouchUpInside += (sender, e) => { try{ categoryService = new CategoryService(); pickerDataModelCategories.Items = categoryService.All(); //llenamos el picker view con la respuesta del servicio de categorias actionSheetPicker.Picker.Source = pickerDataModelCategories; actionSheetPicker.Show(); }catch (System.Net.WebException) { UIAlertView alert = new UIAlertView() { Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet" }; alert.AddButton("Aceptar"); alert.Show(); } catch (System.Exception) { UIAlertView alert = new UIAlertView() { Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo" }; alert.AddButton("Aceptar"); alert.Show(); } }; this.btnPrioridad.TouchUpInside += (sender, e) => { try{ prioritiesService = new PrioritiesService(); pickerDataModel.Items = prioritiesService.All(); //llenamos el pickerview con la lista de prioridades actionSheetPicker.Picker.Source = pickerDataModel; actionSheetPicker.Show(); } catch (System.Net.WebException) { UIAlertView alert = new UIAlertView() { Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet" }; alert.AddButton("Aceptar"); alert.Show(); } catch (System.Exception) { UIAlertView alert = new UIAlertView() { Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo" }; alert.AddButton("Aceptar"); alert.Show(); } }; this.btnFechaCont.TouchUpInside += (sender, e) => { actionSheetDatePicker.Show(); }; this.btnFechaCompr.TouchUpInside += (sender, e) => { actionSheetDatePicker1.Show(); }; //Establecemos las propiedades del primer datepicker actionSheetDatePicker = new ActionSheetDatePicker(this.View); actionSheetDatePicker.Picker.Mode = UIDatePickerMode.Date; actionSheetDatePicker.Picker.TimeZone = NSTimeZone.LocalTimeZone; //actionSheetDatePicker.Picker.MinimumDate = DateTime.Today.AddDays (-7); //actionSheetDatePicker.Picker.MaximumDate = DateTime.Today.AddDays (7); //Establecemos las propiedades del segundo datepicker actionSheetDatePicker1 = new ActionSheetDatePicker(this.View); actionSheetDatePicker1.Picker.Mode = UIDatePickerMode.Date; actionSheetDatePicker1.Picker.TimeZone = NSTimeZone.LocalTimeZone; //actionSheetDatePicker1.Picker.MinimumDate = DateTime.Today.AddDays (-7); //actionSheetDatePicker1.Picker.MaximumDate = DateTime.Today.AddDays (7); actionSheetDatePicker.Picker.ValueChanged += (s, e) => { DateTime fecha1 = (s as UIDatePicker).Date; //DateTime fecha3 = fecha1.AddDays(-1); String fecha2 = String.Format("{0:yyyy-MM-dd}", fecha1); this.lblFechaCont.Text = fecha2; }; actionSheetDatePicker1.Picker.ValueChanged += (s, e) => { DateTime fecha1 = (s as UIDatePicker).Date; //DateTime fecha3 = fecha1.AddDays(-1); String fecha2 = String.Format("{0:yyyy-MM-dd}", fecha1); this.lblFechaCompr.Text = fecha2; }; String categoria = ""; pickerDataModelCategories.ValueChanged += (sender, e) => { categoria = pickerDataModelCategories.SelectedItem.idCategoria; this.lblCategoria.Text = pickerDataModelCategories.SelectedItem.ToString(); }; String prioridad = ""; pickerDataModel.ValueChanged += (sender, e) => { prioridad = pickerDataModel.SelectedItem.idPrioridad; this.lblPrioridad.Text = pickerDataModel.SelectedItem.ToString(); }; String responsable = ""; pickerDataModelResponsibles.ValueChanged += (sender, e) => { responsable = pickerDataModelResponsibles.SelectedItem.UserID; this.lblResponsable.Text = pickerDataModelResponsibles.SelectedItem.ToString(); }; String idPadron = ""; pickerDataModelPeople.ValueChanged += (sender, e) => { idPadron = pickerDataModelPeople.SelectedItem.idPadron; this.cmpSolicitante.Text = pickerDataModelPeople.SelectedItem.ToString(); }; this.btnBuscar.TouchUpInside += (sender, e) => { try{ peopleService = new PeopleService(); peopleService.FindPeople(this.cmpNombre.Text, this.cmpPaterno.Text, this.cmpMaterno.Text); pickerDataModelPeople.Items = peopleService.All(); if (pickerDataModelPeople.Items.Count == 0) { UIAlertView alert = new UIAlertView() { Title = "Persona no encontrada", Message = "No se encontraron resultados, intentelo de nuevo" }; alert.AddButton("Aceptar"); alert.Show(); } else { actionSheetPicker = new ActionSheetPicker(this.View); actionSheetPicker.Picker.Source = pickerDataModelPeople; actionSheetPicker.Show(); } } catch (System.Net.WebException) { UIAlertView alert = new UIAlertView() { Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet" }; alert.AddButton("Aceptar"); alert.Show(); } catch (System.Exception) { UIAlertView alert = new UIAlertView() { Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo" }; alert.AddButton("Aceptar"); alert.Show(); } }; this.cmpSolicitante.Enabled = false; //Se crea el boton para enviar la informacion al servidor this.btnGuardar.TouchUpInside += (sender, e) => { try{ newTaskService = new NewTaskService(); String respuesta = newTaskService.SetData(cmpTitulo.Text, cmpDescripcion.Text, categoria, responsable, prioridad, lblFechaCont.Text, lblFechaCompr.Text, idPadron, MainView.user , cmpTelCasa.Text, cmpTelCel.Text, cmpCorreo.Text, lblLatitud.Text, lblLongitud.Text); if (respuesta.Equals("0")) { UIAlertView alert = new UIAlertView() { Title = "ERROR", Message = "Error del Servidor, intentelo de nuevo" }; alert.AddButton("Aceptar"); alert.Show(); } else if (respuesta.Equals("1")) { UIAlertView alert = new UIAlertView() { Title = "Correcto", Message = "La tarea ha sido guardada correctamente" }; alert.AddButton("Aceptar"); alert.Clicked += (s, o) => { if (o.ButtonIndex == 0) { NavigationController.PopViewControllerAnimated(true); } }; alert.Show(); } }catch (System.Net.WebException ex) { Console.WriteLine(ex.ToString()); UIAlertView alert = new UIAlertView() { Title = "ERROR", Message = "Error del Servidor, intentelo de nuevo, o verifique su conexión a internet" }; alert.AddButton("Aceptar"); alert.Show(); } }; //Se establece un borde para el textarea de las observaciones this.cmpObservaciones.Layer.BorderWidth = 1.0f; this.cmpObservaciones.Layer.BorderColor = UIColor.Gray.CGColor; this.cmpObservaciones.Layer.ShadowColor = UIColor.Black.CGColor; this.cmpObservaciones.Layer.CornerRadius = 8; }
// Load View public override void ViewDidLoad() { try { base.ViewDidLoad(); CLLocationCoordinate2D[] points = new CLLocationCoordinate2D[2]; points[0] = _userLocation; points[1] = _trackCoordinate; points.Count(); RouteLine = MKPolyline.FromCoordinates(points); this.Title = "Tracker"; _mapView = new MKMapView(); _mapView.Frame = new RectangleF(0, 0, this.View.Frame.Width, this.View.Frame.Height); //_mapView.SizeToFit(); //initialize catch touch Events _touchView = new TouchView(new RectangleF(0, 0, this.View.Frame.Width, this.View.Frame.Height)); _touchView.BackgroundColor = UIColor.Clear; _touchView._mapView = _mapView; 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 = MKMapType.Standard; } else if (segmentedControl.SelectedSegment == 1) { _mapView.MapType = MKMapType.Satellite; } else if (segmentedControl.SelectedSegment == 2) { _mapView.MapType = MKMapType.Hybrid; } }; _distanceLbl = new UILabel(); _distanceLbl.Frame = new RectangleF(0, 0, 45, 28); _distanceLbl.BackgroundColor = UIColor.FromRGBA(0.0f, 0.0f, 0.0f, 0.75f); _distanceLbl.TextColor = UIColor.White; _distanceLbl.Font = UIFont.SystemFontOfSize(13); _distanceLbl.Text = "> 9000"; // Add Views this.View.AddSubview(_mapView); View.AddSubview(_touchView); this.View.AddSubview(segmentedControl); this.View.AddSubview(_distanceLbl); // // Map Info Button // var infoButton = UIButton.FromType (UIButtonType.InfoDark); // infoButton.Frame = new RectangleF (288, 14, 22, 22); // infoButton.Title (UIControlState.Normal); // //this.View.AddSubview (infoButton); // // // Map add button // var addButton = UIButton.FromType (UIButtonType.RoundedRect); // addButton.Frame = new RectangleF (288, 44, 22, 22); // addButton.Title (UIControlState.Normal); // //this.View.AddSubview (addButton); // // // Map set Button // var setButton = UIButton.FromType (UIButtonType.RoundedRect); // setButton.Frame = new RectangleF (288, 74, 22, 22); // setButton.Title (UIControlState.Normal); // //this.View.AddSubview (setButton); // Location Mgr _locationMgr = new CLLocationManager(); _locationMgr.Delegate = new LocationDelegate(); _locationMgr.DesiredAccuracy = -1; //best _locationMgr.DistanceFilter = 2; //update every 2 meters?? _locationMgr.StartUpdatingLocation(); _mapView.ShowsUserLocation = true; //show user _mapView.UserLocation.Title = "You are Here!"; _mapView.AddOverlay(RouteLine); // // button events // addButton.TouchUpInside += delegate { _touchView.Hidden = false; }; // // setButton.TouchUpInside += delegate { _touchView.Hidden = true; }; _timer = NSTimer.CreateRepeatingScheduledTimer(TimeSpan.FromSeconds(11), hack); } catch (Exception e) { MessageHelper.showErrorMesage("problem in viewdidload" + e.Message); } }
public override void MonitoringFailed(CLLocationManager manager, CLRegion region, NSError error) { _owner.SendError(ToMvxLocationErrorCode(manager, error, region)); }
public override void RegionEntered(CLLocationManager manager, CLRegion region) => this.Invoke(region, BeaconRegionState.Entered);
public override void RegionLeft(CLLocationManager manager, CLRegion region) => this.Invoke(region, BeaconRegionState.Exited);
public override void RegionLeft(CLLocationManager manager, CLRegion region) { base.RegionLeft(manager, region); Console.WriteLine("Exited Region "); manager.StopRangingBeacons(region as CLBeaconRegion); }
public override void RegionEntered(CLLocationManager manager, CLRegion region) { base.RegionEntered(manager, region); Console.WriteLine("Entered Region"); manager.StartRangingBeacons(region as CLBeaconRegion); }
public override bool ShouldDisplayHeadingCalibration(CLLocationManager manager) => false;
public void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) => AuthorizationStatusChanged?.Invoke(this, new CLAuthorizationChangedEventArgs(status));
public override void DidRangeBeacons(CLLocationManager manager, CLBeacon [] beacons, CLBeaconRegion region) { }
public override void LocationsUpdated(CLLocationManager manager, CLLocation [] locations) { }
public override void Failed(CLLocationManager manager, NSError error) { _owner.SendError(ToMvxLocationErrorCode(manager, error)); }
Task <PermissionStatus> RequestLocationPermission(Permission permission = Permission.Location) { if (CLLocationManager.Status == CLAuthorizationStatus.AuthorizedWhenInUse && permission == Permission.LocationAlways) { //dont' do anything and request it } else if (GetLocationPermissionStatus(permission) != PermissionStatus.Unknown) { return(Task.FromResult(GetLocationPermissionStatus(permission))); } if (!UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { return(Task.FromResult(PermissionStatus.Unknown)); } locationManager = new CLLocationManager(); EventHandler <CLAuthorizationChangedEventArgs> authCallback = null; var tcs = new TaskCompletionSource <PermissionStatus>(); authCallback = (sender, e) => { if (e.Status == CLAuthorizationStatus.NotDetermined) { return; } locationManager.AuthorizationChanged -= authCallback; tcs.TrySetResult(GetLocationPermissionStatus(permission)); }; locationManager.AuthorizationChanged += authCallback; var info = NSBundle.MainBundle.InfoDictionary; if (permission == Permission.Location) { if (info.ContainsKey(new NSString("NSLocationAlwaysUsageDescription"))) { locationManager.RequestAlwaysAuthorization(); } else if (info.ContainsKey(new NSString("NSLocationWhenInUseUsageDescription"))) { locationManager.RequestWhenInUseAuthorization(); } else { throw new UnauthorizedAccessException("On iOS 8.0 and higher you must set either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription in your Info.plist file to enable Authorization Requests for Location updates!"); } } else if (permission == Permission.LocationAlways) { if (info.ContainsKey(new NSString("NSLocationAlwaysUsageDescription"))) { locationManager.RequestAlwaysAuthorization(); } else { throw new UnauthorizedAccessException("On iOS 8.0 and higher you must set either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription in your Info.plist file to enable Authorization Requests for Location updates!"); } } else { if (info.ContainsKey(new NSString("NSLocationWhenInUseUsageDescription"))) { locationManager.RequestWhenInUseAuthorization(); } else { throw new UnauthorizedAccessException("On iOS 8.0 and higher you must set either NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription in your Info.plist file to enable Authorization Requests for Location updates!"); } } return(tcs.Task); }
static BeaconsUtil() { _locationManager = new CLLocationManager(); LastKnownLocation = new CLLocation(); }
public BeaconService() { _locationMgr = new CLLocationManager(); _listOfCLBeaconRegion = new List <CLBeaconRegion> (); }
/// <inheritdoc /> public bool IsMonitoringAvailable(Class regionClass) => // TODO: Rodney gets to fix this CLLocationManager.IsMonitoringAvailable(regionClass);
public override void DeferredUpdatesFinished(CLLocationManager manager, NSError error) => this.deferringUpdates = false;
public override void MonitoringFailed(CLLocationManager manager, CLRegion region, NSError error) { // ignored for now }
public override bool ShouldDisplayHeadingCalibration(CLLocationManager manager) { return(true); }
public override void UpdatedLocation(CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation) { ((GeoLocation)manager).OnUpdatedLocation(newLocation); }
public static IObservable <AccessState> WhenAccessStatusChanged(this CLLocationManager locationManager, bool background) => ((ShinyLocationDelegate)locationManager.Delegate).WhenAccessStatusChanged(background);
public override void AuthorizationChanged(CLLocationManager manager, CLAuthorizationStatus status) { this.Delegate?.AuthorizationChanged(this, this.IsAuthorized); }
public override void GetLocation(Action <bool> action, bool isRefresh = false) { Actions.Add(action); if (!isRefresh && (!LastLatitude.Equals(0) || !LastLongitude.Equals(0))) { RaiseAppOnLocationChanged(true); } else { if (CLLocationManager.Status == CLAuthorizationStatus.Denied) { string title = AppResources.LocationServicesOff; string message = AppResources.TurnOnLocationMessage; IUIAlertViewDelegate alertViewDelegate = null; UIAlertView uiAlertView = new UIAlertView(title, message, alertViewDelegate, AppResources.Cancel, new[] { AppResources.Settings }); uiAlertView.Clicked += (sender, e) => { if (e.ButtonIndex == 1) { var settingsString = UIKit.UIApplication.OpenSettingsUrlString; var url = new NSUrl(settingsString); UIApplication.SharedApplication.OpenUrl(url); } else { if (action != null) { action.Invoke(false); } } }; uiAlertView.Show(); } else { CLLocationManager locMgr = new CLLocationManager(); locMgr.PausesLocationUpdatesAutomatically = false; if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { locMgr.RequestAlwaysAuthorization(); } if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0)) { locMgr.AllowsBackgroundLocationUpdates = true; } if (CLLocationManager.LocationServicesEnabled) { locMgr.DistanceFilter = 5; locMgr.LocationsUpdated += (object sender2, CLLocationsUpdatedEventArgs e2) => { var location = e2.Locations.FirstOrDefault(); if (location != null) { this.LastLongitude = location.Coordinate.Longitude; this.LastLatitude = location.Coordinate.Latitude; RaiseAppOnLocationChanged(true); } }; locMgr.StartUpdatingLocation(); } } } }
public override void UpdatedHeading(CLLocationManager manager, CLHeading newHeading) { // note that we don't immediately send on the heading information. // for user's wanting real-time heading info a different plugin/api will be needed _lastSeenHeading = newHeading; }
static bool LocationManagerShouldDisplayHeadingCalibration(CLLocationManager manager) => ShouldDisplayHeadingCalibration;
public void DidChangeAuthorization(CLLocationManager manager) => AuthorizationStatusChanged?.Invoke(this, new CLAuthorizationChangedEventArgs(manager.AuthorizationStatus));