public MainPage() { this.InitializeComponent(); availableRideTypes = new List <RideType>(); geolocator = new Geolocator(); geolocator.AllowFallbackToConsentlessPositions(); geolocator.ReportInterval = (uint)TimeSpan.FromSeconds(15).TotalSeconds; geolocator.PositionChanged += Geolocator_PositionChanged; driverList = new List <MapElement>(); map.MapServiceToken = Secrets.MapToken; map.BusinessLandmarksVisible = true; //map.LandmarksVisible = true; //map.PedestrianFeaturesVisible = true; //map.TrafficFlowVisible = true; //map.TransitFeaturesVisible = true; placesService = new PlacesService(); placeDetailsService = new PlaceDetailsService(); addressToId = new Dictionary <string, string>(); reverseGeocode = true; loaded = false; }
public AirQualityHelper() { aqi = new AQI(); waqa = new WAQA(); airNowAPI = new AirNowAPI(Secrets.AirNowAPIKey); geolocator = new Geolocator() { DesiredAccuracy = PositionAccuracy.Default, ReportInterval = (uint)TimeSpan.FromMinutes(15).TotalMilliseconds }; geolocator.AllowFallbackToConsentlessPositions(); CurrentWAQA = -1; }
public IObservable <IGpsReading> GetLastReading() => Observable.FromAsync(async ct => { var geolocator = new Geolocator(); geolocator.AllowFallbackToConsentlessPositions(); var location = await geolocator .GetGeopositionAsync() .AsTask(ct); if (location?.Coordinate == null) { return(null); } return(new GpsReading(location.Coordinate)); });
async Task GetTimeOfDay() { Geolocator geolocator = new Geolocator(); geolocator.AllowFallbackToConsentlessPositions(); Geoposition geoposition = await geolocator.GetGeopositionAsync(); HttpResponseMessage astronomyResponse = await httpClient.GetAsync( $"http://api.wunderground.com/api/{Secrets.WundergroundApiKey}/astronomy/q/{geoposition.Coordinate.Point.Position.Latitude},{geoposition.Coordinate.Point.Position.Longitude}.json"); JObject o = JObject.Parse(await astronomyResponse.Content.ReadAsStringAsync()); sunrise = DateTimeHelper(int.Parse((string)o["moon_phase"]["sunrise"]["hour"]), int.Parse((string)o["moon_phase"]["sunrise"]["minute"])); sunset = DateTimeHelper(int.Parse((string)o["moon_phase"]["sunset"]["hour"]), int.Parse((string)o["moon_phase"]["sunset"]["minute"])); }
public async Task <Location?> GetLastKnownLocationAsync() { // no need for permissions as AllowFallbackToConsentlessPositions // will allow the device to return a location regardless var geolocator = new Geolocator { DesiredAccuracy = PositionAccuracy.Default, }; geolocator.AllowFallbackToConsentlessPositions(); var location = await geolocator.GetGeopositionAsync().AsTask(); return(location?.Coordinate?.ToLocation()); }