コード例 #1
0
        private async void OnReverseGeoCodeLocation(object sender, EventArgs e)
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                BindingContext = null;
                var geoService     = new GeoCodingService();
                var reverseResults = await geoService.ReverseGeoCodePosition(vm.Latitude, vm.Longitude);

                vm.Geolocation = reverseResults.FirstOrDefault();

                if (vm.Name == $"{vm.Latitude} / {vm.Longitude}" || vm.Name == null)
                {
                    vm.Name = vm.Geolocation;
                }

                BindingContext = vm;
                // await _dataManager.SaveLocationAsync(vm);
            }
        }
コード例 #2
0
        private async void OnGetCurrentLocation(object sender, EventArgs e)
        {
            BindingContext = null;

            //Get Current Location
            var geoService = new GeoCodingService();

            var results = await geoService.GetCurrentLocation();

            vm.Latitude  = results.Latitude;
            vm.Longitude = results.Longitude;
            vm.Altitude  = results.Altitude;

            if (CrossConnectivity.Current.IsConnected)
            {
                //Reverse GeoCode Results
                var reverseResults = await geoService.ReverseGeoCodePosition(results.Latitude, results.Longitude);

                vm.Geolocation = reverseResults.FirstOrDefault();

                if (vm.Name == null)
                {
                    vm.Name = vm.Geolocation;
                }
            }

            if (vm.Name == null && vm.Geolocation != null)
            {
                vm.Name = vm.Geolocation;
            }
            else if (vm.Name == null)
            {
                vm.Name = $"{vm.Latitude} / {vm.Longitude}";
            }

            // await _dataManager.SaveLocationAsync(vm);

            BindingContext = vm;

            SetMap(vm.Latitude, vm.Longitude);
        }