private async void OnOpenMaps() { if (IsBusy) { return; } IsBusy = true; try { if (Device.RuntimePlatform == Device.iOS) { string endereco = RemoveCarecteres.ObterStringSemAcentosECaracteresEspeciais(Endereco); endereco = endereco.Replace(" ", "+"); await Launcher.TryOpenAsync("http://maps.apple.com/?q=" + endereco); } else if (Device.RuntimePlatform == Device.Android) { string endereco = RemoveCarecteres.ObterStringSemAcentosECaracteresEspeciais(Endereco); endereco = endereco.Replace(" ", "+"); await Launcher.TryOpenAsync("geo:0,0?q=" + endereco); } else if (Device.RuntimePlatform == Device.UWP) { await Map.OpenAsync(new Placemark() { PostalCode = Estagio.Endereco.Cep, Thoroughfare = Estagio.Endereco.Logradouro, Locality = Estagio.Endereco.Localidade, AdminArea = Estagio.Endereco.Uf, SubThoroughfare = Estagio.Endereco.Unidade }); } } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("Erro", ex.Message, "OK"); } finally { IsBusy = false; } }
private void OnBuscarEndereco() { if (IsBusy) { return; } IsBusy = true; try { Endereco.Cep = RemoveCarecteres.ObterStringSemAcentosECaracteresEspeciais(Endereco.Cep); CepError = string.Empty; CepErrorVisible = false; if (MyValidation.ValidarCep(Endereco.Cep)) { var e = Util.Location.GetCEPPosition(Endereco.Cep); if (e != null) { Endereco = e; } } else { CepError = "CEP inválido."; CepErrorVisible = true; } } catch (Exception ex) { Application.Current.MainPage.DisplayAlert("Erro", ex.Message, "Ok"); } finally { IsBusy = false; } }