示例#1
0
        async void GetAddress(Plugin.Geolocator.Abstractions.Position po)
        {
            try
            {
                var resAddress = await GooglePlacesHelper.GetAddress(po.Latitude, po.Longitude);

                if (resAddress != null && resAddress.results.Count > 0)
                {
                    Traverse(resAddress);
                    //ServicioModel.Lat = po.Latitude;
                    //ServicioModel.Lang = po.Longitude;
                    var place = resAddress.results[0];
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        _direccion.Text = place.formatted_address;

                        _direccion.IsVisible      = true;
                        _loadingAddress.IsVisible = false;
                    });
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
示例#2
0
        async void SetLocation(EstadoMapa estado)
        {
            var resAddress = await GooglePlacesHelper.GetAddress(_map.VisibleRegion.Center.Latitude, _map.VisibleRegion.Center.Longitude);

            if (resAddress != null && resAddress.results.Count > 0)
            {
                var place    = resAddress.results[0];
                var refPlace = new ReferenciaMapa()
                {
                    Label    = place.formatted_address,
                    Latitud  = _map.VisibleRegion.Center.Latitude,
                    Longitud = _map.VisibleRegion.Center.Longitude
                };

                if (estado == EstadoMapa.Desde)
                {
                    _desdeRef        = refPlace;
                    _desdeEntry.Text = refPlace.Label;
                }

                if (estado == EstadoMapa.Hasta)
                {
                    _hastaRef        = refPlace;
                    _hastaEntry.Text = refPlace.Label;
                }

                UpdateView();
            }
        }