/// <summary> /// Constructor. /// </summary> public Location() { // Objeto localizador Localizacion = new CLLocationManager(); // Compruebo permisos switch (CLLocationManager.Status) { // Pregunta por autorizacion case CLAuthorizationStatus.NotDetermined: Localizacion.RequestWhenInUseAuthorization(); break; case CLAuthorizationStatus.Restricted: case CLAuthorizationStatus.Denied: Localizacion.RequestWhenInUseAuthorization(); break; case CLAuthorizationStatus.AuthorizedWhenInUse: CompruebaPermisos(); break; case CLAuthorizationStatus.AuthorizedAlways: CompruebaPermisos(); break; } }
void RequestAuthorization() { #if __IOS__ var info = NSBundle.MainBundle.InfoDictionary; if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { if (info.ContainsKey(new NSString("NSLocationAlwaysUsageDescription"))) manager.RequestAlwaysAuthorization(); else if (info.ContainsKey(new NSString("NSLocationWhenInUseUsageDescription"))) manager.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!"); } #elif __MACOS__ //nothing to do here. #elif __TVOS__ var info = NSBundle.MainBundle.InfoDictionary; if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { if (info.ContainsKey(new NSString("NSLocationWhenInUseUsageDescription"))) manager.RequestWhenInUseAuthorization(); else throw new UnauthorizedAccessException("On tvOS 8.0 and higher you must set either NSLocationWhenInUseUsageDescription in your Info.plist file to enable Authorization Requests for Location updates!"); } #endif }
void StartTrackingLocation() { CLAuthorizationStatus status = CLLocationManager.Status; if (status == CLAuthorizationStatus.NotDetermined) { locationManager.RequestWhenInUseAuthorization(); } else if (status == CLAuthorizationStatus.AuthorizedWhenInUse || status == CLAuthorizationStatus.AuthorizedAlways) { locationManager.StartUpdatingLocation(); } }
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 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 override void ViewDidLoad() { base.ViewDidLoad(); SetupNavigationBar(); Title = Constants.MapMarkers; _locationManager = new CLLocationManager(); _locationManager.RequestWhenInUseAuthorization(); _map.ShowsUserLocation = true; MarkerListFromRepository = ViewModel.MarkerList; if (MarkerListFromRepository.Any()) { foreach (MapMarkerEntity coord in MarkerListFromRepository) { _map.AddAnnotations(new MKPointAnnotation() { Title = Constants.MapMarker, Coordinate = new CLLocationCoordinate2D(coord.Latitude, coord.Longitude) }); } } var longPress = new UILongPressGestureRecognizer(LongPress); _map.AddGestureRecognizer(longPress); _map.ShowAnnotations(_map.Annotations, false); View = _map; }
/// <summary> /// Initializes a new instance of the <see cref="Geolocator"/> class. /// </summary> public Geolocator() { _manager = GetManager(); _manager.AuthorizationChanged += OnAuthorizationChanged; _manager.Failed += OnFailed; if (_manager.RespondsToSelector(new Selector("requestWhenInUseAuthorization"))) { _manager.RequestWhenInUseAuthorization(); } if (!CLLocationManager.LocationServicesEnabled) { return; } if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { _manager.LocationsUpdated += OnLocationsUpdated; } else { _manager.UpdatedLocation += OnUpdatedLocation; } _manager.UpdatedHeading += OnUpdatedHeading; }
private Task StartAsync_Impl() { if (_tcs != null) { return(_tcs.Task); } _tcs = new TaskCompletionSource <object>(); new NSObject().InvokeOnMainThread(() => { _locationManager = new CLLocationManager() { DistanceFilter = 1 }; _locationManager.UpdatedLocation += LocationManager_UpdatedLocation; if (CLLocationManager.Status == CLAuthorizationStatus.NotDetermined) { // Request permission to track location and listen for changes to authorization _locationManager.AuthorizationChanged += LocationManager_AuthorizationChanged; _locationManager.RequestWhenInUseAuthorization(); } if (CLLocationManager.Status == CLAuthorizationStatus.AuthorizedWhenInUse || CLLocationManager.Status == CLAuthorizationStatus.AuthorizedAlways || CLLocationManager.Status == CLAuthorizationStatus.Authorized) { _locationManager.StartUpdatingLocation(); _tcs.TrySetResult(null); } }); return(_tcs.Task); }
public override void ViewDidLoad() { base.ViewDidLoad(); var locationManager = new CLLocationManager(); locationManager.RequestWhenInUseAuthorization(); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. locationManager.RequestWhenInUseAuthorization(); Mapa.ShowsUserLocation = true; Segmento.ValueChanged += (object sender, EventArgs e) => { switch (Segmento.SelectedSegment) { case 0: Mapa.MapType = MKMapType.Standard; break; case 1: Mapa.MapType = MKMapType.Satellite; break; case 2: Mapa.MapType = MKMapType.Hybrid; break; default: break; } }; Mapa.AddAnnotation(new MKPointAnnotation() { Title = "Anotacion", Coordinate = new CLLocationCoordinate2D(21.1665143, -101.71766129999999) }); }
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 Location(LisingType lisingType = LisingType.Foreground) { _locMgr = new CLLocationManager { PausesLocationUpdatesAutomatically = false }; if (!UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { return; } switch (lisingType) { case LisingType.Foreground: _locMgr.RequestWhenInUseAuthorization(); // only in foreground break; case LisingType.Background: _locMgr.RequestAlwaysAuthorization(); break; default: throw new ArgumentOutOfRangeException(nameof(lisingType), lisingType, null); } }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); ViewModel.Title = "Acquiring location…"; if (locationManager == null) { locationManager = new CLLocationManager(); locationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters; locationManager.Delegate = this; if (locationManager.RespondsToSelector(new ObjCRuntime.Selector("requestWhenInUseAuthorization"))) { locationManager.RequestWhenInUseAuthorization(); } } StartTimer(); if (Mvx.Resolve <ICacheService>().SearchMode == SearchMode.Now) //park me now { Start60sTimer(); locationManager.StartUpdatingLocation(); Mvx.Resolve <IMvxMessenger>().Publish(new ProgressMessage(this.ViewModel, true, string.Empty, true)); } else //park me later { ViewModel.GetParkingLists(); } ViewModel.UpdateValidTime(); }
public void Initial() { manager = new CLLocationManager(); //manager.Delegate = new MyLocationDelegate(); manager.AllowsBackgroundLocationUpdates = true; manager.RequestWhenInUseAuthorization(); manager.RequestAlwaysAuthorization(); this.beaconregin = new CLBeaconRegion(new NSUuid("FDA50693-A4E2-4FB1-AFCF-C6EB07647826"), "myregion"); this.beaconregin.NotifyEntryStateOnDisplay = true; this.manager.DesiredAccuracy = 100; this.manager.DistanceFilter = 100; this.manager.AllowsBackgroundLocationUpdates = true; //this.manager.LocationsUpdated += Manager_LocationsUpdated; //this.manager.StartRangingBeacons(this.beaconregin); //this.manager.RegionEntered += Manager_RegionEntered; this.manager.DidRangeBeacons += Manager_DidRangeBeacons; //throw new NotImplementedException(); }
public static async Task <AccessState> RequestAccess(this CLLocationManager locationManager, bool background) { var status = locationManager.GetCurrentStatus(background); if (status == AccessState.Available) { return(status); } var task = locationManager .WhenAccessStatusChanged(background) .StartWith() .Take(1) .ToTask(); #if __IOS__ if (background) { locationManager.RequestAlwaysAuthorization(); } else { locationManager.RequestWhenInUseAuthorization(); } #elif !__TVOS__ locationManager.RequestAlwaysAuthorization(); #endif status = await task; return(status); }
public async override void ViewDidLoad() { base.ViewDidLoad(); //Get Location using GeoLocator var location = CrossGeolocator.Current; var position = await location.GetPositionAsync(); CLLocationManager locationManager = new CLLocationManager(); locationManager.RequestWhenInUseAuthorization(); mapView1.MapType = MKMapType.Standard; mapView1.ZoomEnabled = true; mapView1.ScrollEnabled = true; //Set location to mapview CLLocationCoordinate2D mapCenter = new CLLocationCoordinate2D(position.Latitude, position.Longitude); MKCoordinateRegion mapRegion = MKCoordinateRegion.FromDistance(mapCenter, 8000, 8000); mapView1.CenterCoordinate = mapCenter; mapView1.Region = mapRegion; mapView1.ShowsUserLocation = true; lblLatitude.Text = "Latitude:" + position.Latitude.ToString(); lblLongitude.Text = "Longitude:" + position.Longitude.ToString(); }
private static void RequestLocationWhenInUse() { var status = CLLocationManager.Status; if (status != CLAuthorizationStatus.NotDetermined) { RaiseAuthorizationRequested(AuthorizationType.LocationWhenUse, status.ToShared(false)); return; } if (_requests.TryGetValue(AuthorizationType.LocationWhenUse, out var value1)) { var result = _requests.TryUpdate(AuthorizationType.LocationWhenUse, value1 + 1, value1); } else if (_requests.ContainsKey(AuthorizationType.LocationAlways)) { var result = _requests.TryAdd(AuthorizationType.LocationWhenUse, 1); } else { _requests.TryAdd(AuthorizationType.LocationWhenUse, 1); _locationManager = new CLLocationManager(); _locationManager.AuthorizationChanged += OnLocationRequested; _locationManager.RequestWhenInUseAuthorization(); } }
public async Task <GeoCoords> GetGeoCoordinatesAsync() { _manager = new CLLocationManager(); _tcs = new TaskCompletionSource <CLLocation>(); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { _manager.RequestWhenInUseAuthorization(); } _manager.LocationsUpdated += (s, e) => { _tcs.TrySetResult(e.Locations[0]); }; _manager.StartUpdatingLocation(); var location = await _tcs.Task; return(new GeoCoords { Latitude = location.Coordinate.Latitude, Longitude = location.Coordinate.Longitude }); }
public Task <bool> GetGeoLocationPermissionAsync() { var clLocationManager = new CLLocationManager(); if (CLLocationManager.LocationServicesEnabled) { var status = CLLocationManager.Status; bool hasPermission = false; if (status == CLAuthorizationStatus.Authorized || status == CLAuthorizationStatus.AuthorizedAlways || status == CLAuthorizationStatus.AuthorizedWhenInUse) { hasPermission = true; } if (status == CLAuthorizationStatus.Denied || status == CLAuthorizationStatus.Restricted || status == CLAuthorizationStatus.NotDetermined) { hasPermission = false; clLocationManager.RequestWhenInUseAuthorization(); //Device.BeginInvokeOnMainThread(() => UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString))); } return(Task.FromResult(hasPermission)); } return(Task.FromResult(false)); }
private void InitializeMap() { locationManager = new CLLocationManager(); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { locationManager.RequestWhenInUseAuthorization(); } map = new MKMapView(UIScreen.MainScreen.Bounds); View.Add(map); if (CLLocationManager.LocationServicesEnabled) { map.ShowsUserLocation = true; } var centersForDiseaseControlAnnotation = new MKPointAnnotation { Coordinate = new CLLocationCoordinate2D(CDC.Latitude, CDC.Longitude), Title = "Centers for Disease Control", Subtitle = "Zombie Outbreak" }; map.AddAnnotation(centersForDiseaseControlAnnotation); Helpers.CenterOnAtlanta(map); }
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); } }; }
static Task <PermissionStatus> RequestLocationAsync() { locationManager = new CLLocationManager(); var tcs = new TaskCompletionSource <PermissionStatus>(locationManager); locationManager.AuthorizationChanged += LocationAuthCallback; locationManager.RequestWhenInUseAuthorization(); return(tcs.Task); void LocationAuthCallback(object sender, CLAuthorizationChangedEventArgs e) { if (e?.Status == null || e.Status == CLAuthorizationStatus.NotDetermined) { return; } if (locationManager != null) { locationManager.AuthorizationChanged -= LocationAuthCallback; } tcs?.TrySetResult(GetLocationStatus()); locationManager?.Dispose(); locationManager = null; } }
//---method to call to start getting location--- public void ObtainMyLocation() { lm = new CLLocationManager(); lm.DesiredAccuracy = CLLocation.AccuracyBest; lm.DistanceFilter = CLLocationDistance.FilterNone; //---fired whenever there is a change in location--- lm.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { var locations = e.Locations; var strLocation = locations[locations.Length - 1]. Coordinate.Latitude.ToString(); strLocation = strLocation + "," + locations[locations.Length - 1]. Coordinate.Longitude.ToString(); LocationEventArgs args = new LocationEventArgs(); args.lat = locations[locations.Length - 1]. Coordinate.Latitude; args.lng = locations[locations.Length - 1]. Coordinate.Longitude; locationObtained(this, args); }; lm.AuthorizationChanged += (object sender, CLAuthorizationChangedEventArgs e) => { if (e.Status == CLAuthorizationStatus.AuthorizedWhenInUse) { lm.StartUpdatingLocation(); } }; lm.RequestWhenInUseAuthorization(); }
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 async void MapViewInit() { CLLocationManager manager = new CLLocationManager(); manager.RequestWhenInUseAuthorization(); IGeolocator locator = CrossGeolocator.Current; locator.DesiredAccuracy = 50; Position position = await locator.GetPositionAsync(timeoutMilliseconds : 20000); Console.WriteLine("Position Status: {0}", position.Timestamp); Console.WriteLine("Position Latitude: {0}", position.Latitude); Console.WriteLine("Position Longitude: {0}", position.Longitude); CLLocationCoordinate2D mapCenter = new CLLocationCoordinate2D(position.Latitude, position.Longitude); //CLLocationCoordinate2D mapCenter = new CLLocationCoordinate2D(22.617193, 120.3032346); CenterLocation = map.CenterCoordinate = mapCenter; map.Region = MKCoordinateRegion.FromDistance(mapCenter, 1000, 1000); //map.ShowsUserLocation = true; CustomMapViewDelegate customDelegate = new CustomMapViewDelegate(); customDelegate.OnRegionChanged += MapViewOnRegionChanged; map.Delegate = customDelegate; }
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 ObtainMyLocation() { _locationManager = new CLLocationManager { DesiredAccuracy = CLLocation.AccuracyBest, DistanceFilter = CLLocationDistance.FilterNone }; _locationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { var locations = e.Locations; var strLocation = locations[locations.Length - 1].Coordinate.Latitude.ToString(); strLocation = strLocation + "," + locations[locations.Length - 1].Coordinate.Longitude.ToString(); LocationEventArgs args = new LocationEventArgs { Latitude = locations[locations.Length - 1].Coordinate.Latitude, Longitude = locations[locations.Length - 1].Coordinate.Longitude }; LocationObtained(this, args); }; _locationManager.AuthorizationChanged += (object sender, CLAuthorizationChangedEventArgs e) => { if (e.Status == CLAuthorizationStatus.AuthorizedWhenInUse) { _locationManager.StartUpdatingLocation(); } }; _locationManager.RequestWhenInUseAuthorization(); }
public override void ViewDidLoad() { base.ViewDidLoad(); ApplyStylesToViews(); locationManager.RequestAlwaysAuthorization(); locationManager.RequestWhenInUseAuthorization(); locationManager.DesiredAccuracy = CLLocation.AccuracyBest; locationManager.LocationsUpdated += LocationManager_LocationsUpdated; locationManager.StartUpdatingLocation(); mapHelper = new MapHelperFunctions("AIzaSyAZQBaY-ugQuwCWr4NkD-bybK7urElvNyY", googleMap); pickupButtonBar.TouchUpInside += PickupButtonBar_TouchUpInside; destinationButtonBar.TouchUpInside += DestinationButtonBar_TouchUpInside; doneButton.TouchUpInside += DoneButton_TouchUpInside; requestCabButton.TouchUpInside += RequestCabButton_TouchUpInside; cancelRequestButton.TouchUpInside += CancelRequestButton_TouchUpInside; menuButton.UserInteractionEnabled = true; menuButton.AddGestureRecognizer(new UITapGestureRecognizer(() => { if (tripStage == 0) { // display our side menu } else if (tripStage == 1) { UIView.Animate(0.2, HideTripDetailsView); ClearTripOnMap(); } })); }
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 static async Task <AccessState> RequestAccess(this CLLocationManager locationManager, bool background) { var status = locationManager.GetCurrentStatus(background); if (status != AccessState.Unknown) { return(status); } var task = locationManager .WhenAccessStatusChanged(background) .Take(1) .ToTask(); if (background) { locationManager.RequestAlwaysAuthorization(); } else { locationManager.RequestWhenInUseAuthorization(); } status = await task; return(status); }
public override void ViewDidLoad() { base.ViewDidLoad(); //Your Google Dev. Console API Key (with iOS Google Maps SDK enabled!) var success = MapServices.ProvideAPIKey(Your API Key Here); mapServices = MapServices.SharedServices; var button = new UIButton(UIButtonType.System); button.Frame = new CGRect(40, 40, 200, 40); button.SetTitle("Track My Movement", UIControlState.Normal); Add(button); button.TouchUpInside += (object sender, EventArgs e) => { mapView = new MapView(UIScreen.MainScreen.Bounds); mapView.MapType = MapViewType.Hybrid; Add(mapView); mapView.AddObserver(this, new NSString("myLocation"), NSKeyValueObservingOptions.New, IntPtr.Zero); mapView.MyLocationEnabled = true; locationManager = new CLLocationManager(); locationManager.DesiredAccuracy = CLLocation.AccuracyBest; locationManager.DistanceFilter = 0; locationManager.RequestWhenInUseAuthorization(); locationManager.LocationsUpdated += (object sender2, CLLocationsUpdatedEventArgs e2) => { Console.WriteLine(e2.Locations[e2.Locations.Length - 1]); }; locationManager.StartUpdatingLocation(); }; }
public override void ViewDidLoad() { base.ViewDidLoad(); CLLocationManager locationManager = new CLLocationManager(); if (locationManager.RespondsToSelector(new ObjCRuntime.Selector("requestWhenInUseAuthorization"))) { locationManager.RequestWhenInUseAuthorization(); } MKPointAnnotation pinView = new MKPointAnnotation(); pinView.Title = "Teste"; pinView.SetCoordinate(new CoreLocation.CLLocationCoordinate2D(-23.548428, -46.631834)); mapa.AddAnnotation(pinView); mapa.Camera = new MKMapCamera() { CenterCoordinate = new CoreLocation.CLLocationCoordinate2D(-23.548428, -46.631834), Altitude = 3000 }; // Perform any additional setup after loading the view, typically from a nib. }
public async override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. LocationManager = new CLLocationManager(); LocationManager.RequestWhenInUseAuthorization(); LocationManager.DistanceFilter = CLLocationDistance.FilterNone; LocationManager.DesiredAccuracy = 1000; LocationManager.LocationsUpdated += LocationManager_LocationsUpdated; LocationManager.StartUpdatingLocation(); PointOfInterest.GetCurrentPOIAsync = async() => { await Task.Run(() => waitEvent.WaitOne()); return(currentPOI); }; var source = new TableSource(await PointOfInterest.GetGlobalListAsync()); source.OnClick += Source_OnClick; MyTable.Source = source; MyTable.ReloadData(); }
public async Task <Coordinates> GetCoordinatesAsync() { var locationManager = new CLLocationManager(); _locationTaskCompletion = new TaskCompletionSource <CLLocation>(); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { locationManager.RequestWhenInUseAuthorization(); } locationManager.LocationsUpdated += OnLocationUpdated; locationManager.StartUpdatingLocation(); var location = await _locationTaskCompletion.Task; var result = new Coordinates { Latitude = location.Coordinate.Latitude, Longitude = location.Coordinate.Longitude }; return(result); }
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 RangingVC (IntPtr handle) : base (handle) { SetUpHue (); //set up sqlite db var documents = Environment.GetFolderPath (Environment.SpecialFolder.Personal); _pathToDatabase = Path.Combine (documents, "db_sqlite-net.db"); region = new CLBeaconRegion (AppDelegate.BeaconUUID, "BeaconSample");//ushort.Parse ("26547"), ushort.Parse ("56644"), region.NotifyOnEntry = true; region.NotifyOnExit = true; locationManager = new CLLocationManager (); locationManager.RequestWhenInUseAuthorization (); locationManager.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => { if (e.Beacons.Length > 0) { CLBeacon beacon = e.Beacons [0]; switch (beacon.Proximity) { case CLProximity.Immediate: SetImmediateColor(); message = "Immediate"; break; case CLProximity.Near: message = "Near"; SetNearColor(); break; case CLProximity.Far: message = "Far"; SetFarColor(); break; case CLProximity.Unknown: message = "Unknown"; SetUnknownColor(); break; } if (previousProximity != beacon.Proximity) { Console.WriteLine (message); } previousProximity = beacon.Proximity; } }; locationManager.StartRangingBeacons (region); var db = new SQLite.SQLiteConnection (_pathToDatabase); var bridgeIp = db.Table<HueBridge> ().ToArray (); client = new LocalHueClient (bridgeIp [0].HueBridgeIpAddress); client.Initialize ("pooberry"); }
public override void ViewDidLoad () { // all your base base.ViewDidLoad (); // load the appropriate view, based on the device type this.LoadViewForDevice (); // initialize our location manager and callback handler iPhoneLocationManager = new CLLocationManager (); // uncomment this if you want to use the delegate pattern: //locationDelegate = new LocationDelegate (mainScreen); //iPhoneLocationManager.Delegate = locationDelegate; // you can set the update threshold and accuracy if you want: //iPhoneLocationManager.DistanceFilter = 10; // move ten meters before updating //iPhoneLocationManager.HeadingFilter = 3; // move 3 degrees before updating // you can also set the desired accuracy: iPhoneLocationManager.DesiredAccuracy = 1000; // 1000 meters/1 kilometer // you can also use presets, which simply evalute to a double value: //iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters; // handle the updated location method and update the UI if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) { iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { UpdateLocation (mainScreen, e.Locations [e.Locations.Length - 1]); }; } else { #pragma warning disable 618 // this won't be called on iOS 6 (deprecated) iPhoneLocationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => { UpdateLocation (mainScreen, e.NewLocation); }; #pragma warning restore 618 } //iOS 8 requires you to manually request authorization now - Note the Info.plist file has a new key called requestWhenInUseAuthorization added to. if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { iPhoneLocationManager.RequestWhenInUseAuthorization(); } // handle the updated heading method and update the UI iPhoneLocationManager.UpdatedHeading += (object sender, CLHeadingUpdatedEventArgs e) => { mainScreen.LblMagneticHeading.Text = e.NewHeading.MagneticHeading.ToString () + "º"; mainScreen.LblTrueHeading.Text = e.NewHeading.TrueHeading.ToString () + "º"; }; // start updating our location, et. al. if (CLLocationManager.LocationServicesEnabled) iPhoneLocationManager.StartUpdatingLocation (); if (CLLocationManager.HeadingAvailable) iPhoneLocationManager.StartUpdatingHeading (); }
public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. // request location access from user CLLocationManager lm = new CLLocationManager(); lm.RequestWhenInUseAuthorization(); }
public override void ViewDidLoad() { base.ViewDidLoad(); var locationManager = new CLLocationManager(); locationManager.RequestWhenInUseAuthorization(); var peripheralData = _beaconRegion.GetPeripheralData(null); _peripheralManager.StartAdvertising(peripheralData); }
public override void ViewDidLoad () { base.ViewDidLoad (); // get access locationManager = new CLLocationManager (); locationManager.RequestWhenInUseAuthorization (); // create the annotation var sdAnnotation = new MKPointAnnotation { Title = "SDWebImage Annotation", }; // create the view string pId = "sdwebimage"; mapView.GetViewForAnnotation = (mapView, annotation) => { if (annotation is MKUserLocation) return null; // create annotation view var pinView = mapView.DequeueReusableAnnotation (pId); if (pinView == null) { pinView = new MKAnnotationView (annotation, pId); // get the image pinView.SetImage ( new NSUrl ("http://radiotray.sourceforge.net/radio.png"), UIImage.FromBundle ("placeholder.png"), (image, error, cacheType, imageUrl) => { if (error != null) { Console.WriteLine ("Error: " + error); } else { Console.WriteLine ("Done: " + pinView.GetImageUrl ()); } }); } return pinView; }; // add the annotation mapView.AddAnnotation (sdAnnotation); // move it mapView.DidUpdateUserLocation += (sender, e) => { var loc = e.UserLocation.Coordinate; sdAnnotation.Coordinate = new CLLocationCoordinate2D (loc.Latitude, loc.Longitude); mapView.SetCenterCoordinate (sdAnnotation.Coordinate, true); }; // start tracking mapView.ShowsUserLocation = true; }
public override void ViewDidLoad () { base.ViewDidLoad (); //set up sqlite db var documents = Environment.GetFolderPath (Environment.SpecialFolder.Personal); _pathToDatabase = Path.Combine (documents, "db_sqlite-net.db"); TryToConnectToBridge (); utilityManager = new UtilityManager (); beaconManager = new BeaconManager (); locationManager = new CLLocationManager (); locationManager.RequestWhenInUseAuthorization (); beaconManager.AuthorizationStatusChanged += (sender, e) => { beaconManager.StartMonitoringForRegion (region); }; beaconManager.ExitedRegion += (sender, e) => { proximityValueLabel.Text = "You have EXITED the PooBerry region"; }; locationManager.DidDetermineState += (object sender, CLRegionStateDeterminedEventArgs e) => { switch (e.State) { case CLRegionState.Inside: OnAdd (); Console.WriteLine ("region state inside"); break; case CLRegionState.Outside: Console.WriteLine ("region state outside"); StartMonitoringBeacons (); break; case CLRegionState.Unknown: default: Console.WriteLine ("region state unknown"); StartMonitoringBeacons (); break; } }; locationManager.RegionEntered += (object sender, CLRegionEventArgs e) => { Console.WriteLine ("beacon region entered"); }; #region Hue UI connectBridge.TouchUpInside += ConnectBridgeClicked; onButton.TouchUpInside += OnButton_TouchUpInside; offButton.TouchUpInside += OffButton_TouchUpInside; #endregion Hue UI }
protected override void PlatformSpecificStart(MvxLocationOptions options) { lock (this) { if (_locationManager != null) throw new MvxException("You cannot start the MvxLocation service more than once"); _locationManager = new CLLocationManager(); _locationManager.Delegate = new LocationDelegate(this); if (options.MovementThresholdInM > 0) { _locationManager.DistanceFilter = options.MovementThresholdInM; } else { _locationManager.DistanceFilter = CLLocationDistance.FilterNone; } _locationManager.DesiredAccuracy = options.Accuracy == MvxLocationAccuracy.Fine ? CLLocation.AccuracyBest : CLLocation.AccuracyKilometer; if (options.TimeBetweenUpdates > TimeSpan.Zero) { Mvx.Warning("TimeBetweenUpdates specified for MvxLocationOptions - but this is not supported in iOS"); } if (options.TrackingMode == MvxLocationTrackingMode.Background) { if (IsIOS8orHigher) { _locationManager.RequestAlwaysAuthorization (); } else { Mvx.Warning ("MvxLocationTrackingMode.Background is not supported for iOS before 8"); } } else { if (IsIOS8orHigher) { _locationManager.RequestWhenInUseAuthorization (); } } if (CLLocationManager.HeadingAvailable) _locationManager.StartUpdatingHeading(); _locationManager.StartUpdatingLocation(); } }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { AppDelegate.Self = this; global::Xamarin.Forms.Forms.Init(); App.ScreenSize = new Size(UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height); LoadApplication(new App()); LocationManager = new CLLocationManager(); var iOSVersion = UIDevice.CurrentDevice.SystemVersion.Split('.'); if (Convert.ToInt32(iOSVersion[0]) >= 8) { LocationManager.RequestAlwaysAuthorization(); LocationManager.RequestWhenInUseAuthorization(); } return base.FinishedLaunching(app, options); }
public void StartLocationManager() { LocationManager = new CLLocationManager(); //if (LocationManager.RespondsToSelector(new MonoTouch.ObjCRuntime.Selector("requestWhenInUseAuthorization"))) LocationManager.RequestWhenInUseAuthorization(); LocationManager.DistanceFilter = CLLocationDistance.FilterNone; LocationManager.DesiredAccuracy = CLLocation.AccuracyBest; LocationManager.LocationsUpdated += LocationManager_LocationsUpdated; LocationManager.StartUpdatingLocation(); _isTracking = true; System.Diagnostics.Debug.WriteLine("Location manager started "); }
public override void ViewDidLoad() { base.ViewDidLoad(); map.SetRegion( new MKCoordinateRegion( centerPosition, // 初期位置 new MKCoordinateSpan(0.1d, 0.1d)), true); locMgr = new CLLocationManager(); locMgr.RequestWhenInUseAuthorization(); button.TouchUpInside += (s, _) => { locMgr.DesiredAccuracy = 1000; locMgr.LocationsUpdated += async (object sender, CLLocationsUpdatedEventArgs e) => { var location = e.Locations[e.Locations.Length - 1]; LatitudeText.Text = "Lat: " + location.Coordinate.Latitude.ToString("N6"); LongitudeText.Text = "Lon: " + location.Coordinate.Longitude.ToString("N6"); // PCL で Google Maps API Web サービスに Lat, Lon を投げて住所を取得しています。 var addr = await getAddress.GetJsonAsync(location.Coordinate.Latitude, location.Coordinate.Longitude) ?? "取得できませんでした"; System.Diagnostics.Debug.WriteLine("AddressResult", addr); AddrText.Text = "Address: " + addr; // Map 移動 map.SetRegion( new MKCoordinateRegion( new CLLocationCoordinate2D(location.Coordinate.Latitude, location.Coordinate.Longitude), new MKCoordinateSpan(0.1d, 0.1d)), true); // Pin 追加 map.AddAnnotations(new MKPointAnnotation() { Title = addr, Coordinate = new CLLocationCoordinate2D(location.Coordinate.Latitude, location.Coordinate.Longitude) }); locMgr.StopUpdatingLocation(); }; locMgr.StartUpdatingLocation(); // なぜ下に書くのかあめいさんに聞いてみよう。 }; }
public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. var LocationManager = new CLLocationManager(); LocationManager.RequestWhenInUseAuthorization (); LocationManager.RequestAlwaysAuthorization (); CLCircularRegion region = new CLCircularRegion (new CLLocationCoordinate2D (+46.833120, +15.34901), 1000.0, "FF Gussendorf"); if (CLLocationManager.LocationServicesEnabled) { LocationManager.DidStartMonitoringForRegion += (o, e) => { Console.WriteLine ("Now monitoring region {0}", e.Region.ToString ()); }; LocationManager.RegionEntered += (o, e) => { Console.WriteLine ("Just entered " + e.Region.ToString ()); }; LocationManager.RegionLeft += (o, e) => { Console.WriteLine ("Just left " + e.Region.ToString ()); }; LocationManager.Failed += (o, e) => { Console.WriteLine (e.Error); }; LocationManager.UpdatedLocation += (o, e) => { Console.WriteLine ("Lat " + e.NewLocation.Coordinate.Latitude + ", Long " + e.NewLocation.Coordinate.Longitude); }; LocationManager.LocationsUpdated += (o, e) => Console.WriteLine ("Location change received"); LocationManager.StartMonitoring (region); LocationManager.StartMonitoringSignificantLocationChanges (); //LocationManager.StopMonitoringSignificantLocationChanges (); } else { Console.WriteLine ("This app requires region monitoring, which is unavailable on this device"); } }
void InitializeMap () { locationManager = new CLLocationManager (); if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) { locationManager.RequestWhenInUseAuthorization (); } map = new MKMapView (UIScreen.MainScreen.Bounds); View.Add (map); if (CLLocationManager.LocationServicesEnabled) { map.ShowsUserLocation = true; } Helpers.CenterOnCheyenne (map); }
public override void ViewDidLoad() { base.ViewDidLoad(); locMgr = new CLLocationManager(); locMgr.RequestWhenInUseAuthorization(); button.TouchUpInside += (s, _) => { locMgr.DesiredAccuracy = 1000; locMgr.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => { var location = e.Locations[e.Locations.Length - 1]; LatText.Text = "Latitude: " + location.Coordinate.Latitude.ToString(); LonText.Text = "Longitude: " + location.Coordinate.Longitude.ToString(); }; locMgr.StartUpdatingLocation(); }; }
// // This method is invoked when the application has loaded and is ready to run. In this // method you should instantiate the window, load the UI into it and then make the window // visible. // // You have 17 seconds to return from this method, or iOS will terminate your application. // public override bool FinishedLaunching(UIApplication app, NSDictionary options) { locationManager = new CLLocationManager(); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { locationManager.RequestWhenInUseAuthorization(); } // create a new window instance based on the screen size window = new UIWindow(UIScreen.MainScreen.Bounds); // If you have defined a view, add it here: window.RootViewController = new MainViewController(); // make the window visible window.MakeKeyAndVisible(); return true; }
/// <summary> /// Initializes a new instance of the <see cref="Geolocator"/> class. /// </summary> public Geolocator() { _manager = GetManager(); _manager.AuthorizationChanged += OnAuthorizationChanged; _manager.Failed += OnFailed; if (_manager.RespondsToSelector(new Selector("requestWhenInUseAuthorization"))) { _manager.RequestWhenInUseAuthorization(); } if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { _manager.LocationsUpdated += OnLocationsUpdated; } else { _manager.UpdatedLocation += OnUpdatedLocation; } _manager.UpdatedHeading += OnUpdatedHeading; }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { MapServices.ProvideAPIKey ("AIzaSyA8WOvgGyHaw3rgkeYuUIqkIxhmW9Hrdjc"); locationManager = new CLLocationManager (); locationManager.Delegate = new locationManagerDelegate (); locationManager.DesiredAccuracy = CLLocation.AccuracyBest; locationManager.RequestAlwaysAuthorization (); if (locationManager.RespondsToSelector (new Selector ("requestWhenInUseAuthorization"))) { locationManager.RequestWhenInUseAuthorization (); } if (CLLocationManager.LocationServicesEnabled) { locationManager.StartUpdatingLocation (); } ProgressHUD.Shared.HudForegroundColor = UIColor.Gray; ProgressHUD.Shared.Ring.Color = UIColor.FromRGB(44/255f,146/255f,208/255f); ProgressHUD.Shared.HudForegroundColor = UIColor.FromRGB(44/255f,146/255f,208/255f); UIApplication.SharedApplication.SetStatusBarStyle (UIStatusBarStyle.LightContent, true); this.Window = new UIWindow (UIScreen.MainScreen.Bounds); UINavigationController navigation = new UINavigationController(new StartingScreen()); navigation.NavigationBar.TintColor = UIColor.White; navigation.NavigationBar.BarTintColor = UIColor.FromRGB(44/255f,146/255f,208/255f); navigation.NavigationBar.BarStyle = UIBarStyle.Black; navigation.SetNavigationBarHidden (true,true); this.Window.RootViewController = navigation; this.Window.MakeKeyAndVisible (); return true; }
private CLLocationManager GetManager() { CLLocationManager m = null; new NSObject().InvokeOnMainThread(() => { m = new CLLocationManager(); m.RequestWhenInUseAuthorization(); }); return m; }
public override void ViewDidLoad() { base.ViewDidLoad (); if (!UserInterfaceIdiomIsPhone) { openMultipeerBrowser.TouchUpInside += (sender, e) => { StartMultipeerBrowser (); }; } else { StartMultipeerAdvertiser (); } var monkeyUUID = new NSUuid (uuid); beaconRegion = new CLBeaconRegion (monkeyUUID, monkeyId); beaconRegion.NotifyEntryStateOnDisplay = true; beaconRegion.NotifyOnEntry = true; beaconRegion.NotifyOnExit = true; if (UserInterfaceIdiomIsPhone) { InitPitchAndVolume (); locationMgr = new CLLocationManager (); locationMgr.RequestWhenInUseAuthorization (); locationMgr.RegionEntered += (object sender, CLRegionEventArgs e) => { if (e.Region.Identifier == monkeyId) { UILocalNotification notification = new UILocalNotification () { AlertBody = "There's a monkey hiding nearby!" }; UIApplication.SharedApplication.PresentLocationNotificationNow (notification); } }; locationMgr.DidRangeBeacons += (object sender, CLRegionBeaconsRangedEventArgs e) => { if (e.Beacons.Length > 0) { CLBeacon beacon = e.Beacons [0]; string message = ""; switch (beacon.Proximity) { case CLProximity.Immediate: message = "You found the monkey!"; monkeyStatusLabel.Text = message; View.BackgroundColor = UIColor.Green; break; case CLProximity.Near: message = "You're getting warmer"; monkeyStatusLabel.Text = message; View.BackgroundColor = UIColor.Yellow; break; case CLProximity.Far: message = "You're freezing cold"; monkeyStatusLabel.Text = message; View.BackgroundColor = UIColor.Blue; break; case CLProximity.Unknown: message = "I'm not sure how close you are to the monkey"; monkeyStatusLabel.Text = message; View.BackgroundColor = UIColor.Gray; break; } if (previousProximity != beacon.Proximity) { Speak (message); // demo send message using multipeer connectivity if (beacon.Proximity == CLProximity.Immediate) SendMessage (); } previousProximity = beacon.Proximity; } }; locationMgr.StartMonitoring (beaconRegion); locationMgr.StartRangingBeacons (beaconRegion); } }
void UpdateIsShowingUser() { if (FormsMaps.IsiOs8OrNewer && ((Map)Element).IsShowingUser) { _locationManager = new CLLocationManager(); _locationManager.RequestWhenInUseAuthorization(); } ((MKMapView)Control).ShowsUserLocation = ((Map)Element).IsShowingUser; }
private async Task<NSDictionary> BuildGPSDataAsync() { // setup the location manager if (_locationManager == null) { _locationManager = new CLLocationManager(); if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) _locationManager.RequestWhenInUseAuthorization(); _locationManager.DesiredAccuracy = 1; // in meters } // setup a task for getting the current location and a callback for receiving the location _locationTCS = new TaskCompletionSource<CLLocation>(); _locationManager.LocationsUpdated += (sender, locationArgs) => { if (locationArgs.Locations.Length > 0) { _locationManager.StopUpdatingLocation(); _locationTCS.TrySetResult(locationArgs.Locations[locationArgs.Locations.Length - 1]); } }; // start location monitoring _locationManager.StartUpdatingLocation(); // create a timeout and location task to ensure we don't wait forever var timeoutTask = System.Threading.Tasks.Task.Delay(5000); // 5 second wait var locationTask = _locationTCS.Task; // try and set a location based on whatever task ends first CLLocation location; var completeTask = await System.Threading.Tasks.Task.WhenAny(locationTask, timeoutTask); if (completeTask == locationTask && completeTask.Status == TaskStatus.RanToCompletion) { // use the location result location = locationTask.Result; } else { // timeout - stop the location manager and try and use the last location _locationManager.StopUpdatingLocation(); location = _locationManager.Location; } if (location == null) return null; var gpsData = new NSDictionary( ImageIO.CGImageProperties.GPSLatitude, Math.Abs(location.Coordinate.Latitude), ImageIO.CGImageProperties.GPSLatitudeRef, (location.Coordinate.Latitude >= 0) ? "N" : "S", ImageIO.CGImageProperties.GPSLongitude, Math.Abs(location.Coordinate.Longitude), ImageIO.CGImageProperties.GPSLongitudeRef, (location.Coordinate.Longitude >= 0) ? "E" : "W", ImageIO.CGImageProperties.GPSAltitude, Math.Abs(location.Altitude), ImageIO.CGImageProperties.GPSDateStamp, DateTime.UtcNow.ToString("yyyy:MM:dd"), ImageIO.CGImageProperties.GPSTimeStamp, DateTime.UtcNow.ToString("HH:mm:ss.ff") ); return gpsData; }
public override void ViewDidLoad() { base.ViewDidLoad(); var path = NSBundle.MainBundle.PathForResource("ashland.gpx", null); var url = NSUrl.FromFilename(path); locationManager = new CLLocationManager(); locationManager.RequestWhenInUseAuthorization(); locationManager.Delegate = this; locationManager.StartUpdatingLocation(); }
public override void ViewDidLoad () { base.ViewDidLoad (); _locationManager = new CLLocationManager { DesiredAccuracy = 1000 }; _locationManager.RequestWhenInUseAuthorization (); if (Vm.Conference.IsAddedToSchedule) { SetRemoveButtonStatus(); } else { SetAddButtonStatus(); } addToMySchedule.Layer.BorderColor = UIColor.LightGray.CGColor; addToMySchedule.Layer.BorderWidth = 0.5f; addToMySchedule.TouchUpInside += (sender, e) => { var settingsService = ServiceLocator.Current.GetInstance<ISettingsService>(); if (!string.IsNullOrWhiteSpace(settingsService.UserIdToken)) { if (Vm.Conference.IsAddedToSchedule) { Vm.RemoveFromScheduleCommand.Execute(null); } else { Vm.AddToScheduleCommand.Execute(null); } } else { new UIAlertView("Login", "You must login to add a conference to your schedule", null, "Ok", null).Show(); } }; Messenger.Default.Register<ConferenceAddedToScheduleMessage> ( this, (message) => SetRemoveButtonStatus () ); Messenger.Default.Register<ConferenceRemovedFromScheduleMessage> ( this, (message) => SetAddButtonStatus () ); viewSessions.Layer.BorderColor = UIColor.LightGray.CGColor; viewSessions.Layer.BorderWidth = 0.5f; var sessionCount = Vm?.Conference?.Sessions?.Count (); viewSessions.SetTitle ($"View {sessionCount} Sessions", UIControlState.Normal); this.Title = Vm.Conference.Name; conferenceName.Text = Vm.Conference.Name; conferenceName.SizeToFit (); conferenceDescription.Text = Vm.Conference.Description; conferenceDescription.SizeToFit (); conferenceStartDate.Text = Vm.DateRange; conferenceStartDate.SizeToFit (); SetConferenceLocationButton (Vm.Conference.Address.AddressLongDisplay ()); conferenceAddress.SizeToFit (); GetImage (Vm.Conference); ShowMap (); }
void ShowActualLocationPermissionAlert() { _locationManager = new CLLocationManager (); _locationManager.Delegate = new LocationManagerDelegate (this); if (_locationAuthorizationType == ClusterLocationAuthorizationType.Always && _locationManager.RespondsToSelector (new Selector ("requestAlwaysAuthorization"))) { _locationManager.RequestAlwaysAuthorization (); } else if (_locationAuthorizationType == ClusterLocationAuthorizationType.WhenInUse && _locationManager.RespondsToSelector (new Selector ("requestWhenInUseAuthorization"))) { _locationManager.RequestWhenInUseAuthorization (); } _locationManager.StartUpdatingLocation (); }
private void InitializeMap() { locationManager = new CLLocationManager (); if (UIDevice.CurrentDevice.CheckSystemVersion (8, 0)) { locationManager.RequestWhenInUseAuthorization (); } map = new MKMapView (UIScreen.MainScreen.Bounds); View.Add (map); if (CLLocationManager.LocationServicesEnabled) { map.ShowsUserLocation = true; } var centersForDiseaseControlAnnotation = new MKPointAnnotation { Coordinate = new CLLocationCoordinate2D (CDC.Latitude, CDC.Longitude), Title = "Centers for Disease Control", Subtitle = "Zombie Outbreak" }; map.AddAnnotation (centersForDiseaseControlAnnotation); Helpers.CenterOnAtlanta (map); }
public GameDetailViewController (IntPtr handle) : base (handle) { locationManager = new CLLocationManager(); locationManager.RequestWhenInUseAuthorization(); }