示例#1
0
        private async Task GetPlaceDetail(string place)
        {
            var result = await Service.GetPlaceDetail(place);

            if (result.status == "OK")
            {
                var googleResult = result.result;
                SelectedLocation = googleResult.geometry.location;
                FormattedAddress = googleResult.formatted_address;
                GooglePlaceId    = googleResult.place_id;
                SelectionMode    = AddressSelectionMode.Autocomplete;
                MessagingCenter.Send(this, "ResultFromGMaps", googleResult.geometry.location);
            }
            else if (result.status == "REQUEST_DENIED")
            {
                await Application.Current.MainPage.DisplayAlert("Warning", "Please enter API Key in PlaceService.cs", "Okay");
            }
            else if (result.status == "OVER_QUERY_LIMIT" || result.status == "OVER_DAILY_LIMIT" || result.status == "MAX_ELEMENTS_EXCEEDED")
            {
                await Application.Current.MainPage.DisplayAlert("Warning", result.status, "Okay");
            }
            else
            {
                if (PlaceSearchAutoComplete != null)
                {
                    PlaceSearchAutoComplete = new ObservableCollection <Prediction>();
                }
            }
        }
 public void SetAddressSelectionMode(AddressSelectionMode mode = AddressSelectionMode.None)
 {
     _addressSelectionModeSubject.OnNext(mode);
 }