Esempio n. 1
0
        public async Task <LocationAddress> GetLocationAddress(double latitude, double longitude)
        {
            var geoCoder   = new CLGeocoder();
            var place      = new CLLocation(latitude, longitude);
            var placemarks = await geoCoder.ReverseGeocodeLocationAsync(place);

            if (placemarks.Any())
            {
                var placeMark = placemarks.First();

                var location = new LocationAddress()
                {
                    Name     = placeMark.Name,
                    City     = placeMark.Locality,
                    Province = placeMark.AdministrativeArea,
                    ZipCode  = placeMark.PostalCode,
                    Country  = $"{placeMark.Country} ({placeMark.IsoCountryCode})",
                    Address  = new CNPostalAddressFormatter().StringFor(placeMark.PostalAddress)
                };

                return(location);
            }

            return(null);
        }
Esempio n. 2
0
        public async Task <Address[]> GetAddressesAsync(double latitude, double longitude)
        {
            var geocoder   = new CLGeocoder();
            var placemarks = await geocoder.ReverseGeocodeLocationAsync(new CLLocation(latitude, longitude));

            return(placemarks.Select(Convert).ToArray());
        }
Esempio n. 3
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();
            mpMapa.ShowsUserLocation = true;
            var Localizador = CrossGeolocator.Current;
            var Posicion    = await Localizador.GetPositionAsync(TimeSpan.FromSeconds(10), null, true); //obtener la posición cada 10 segundos.

            var Ubicacion     = new CLLocation(Posicion.Latitude, Posicion.Longitude);
            var Georeferencia = new CLGeocoder();
            var DatosGeo      = await Georeferencia.ReverseGeocodeLocationAsync(Ubicacion);


            Latitud  = Posicion.Latitude;
            Longitud = Posicion.Longitude;

            lblCiudad.Text       = DatosGeo[0].Locality;
            lblDepartamento.Text = DatosGeo[0].AdministrativeArea;
            lblLatitud.Text      = Latitud.ToString();
            lblLongitud.Text     = Longitud.ToString();
            lblMunicipio.Text    = DatosGeo[0].SubLocality;
            lblPais.Text         = DatosGeo[0].Country;
            txtDescripcion.Text  = DatosGeo[0].Description;

            mpMapa.MapType = MapKit.MKMapType.HybridFlyover; //Se establece el tipo de mapa
            var CentrarMapa = new CLLocationCoordinate2D(Latitud, Longitud);
            var AlturaMapa  = new MKCoordinateSpan(.003, .003);
            var Region      = new MKCoordinateRegion(CentrarMapa, AlturaMapa);

            mpMapa.SetRegion(Region, true);
        }
Esempio n. 4
0
        protected void AgregoMapa()
        {
            map.MapType = MKMapType.Standard;
            map.Bounds  = UIScreen.MainScreen.Bounds;           //full screen baby

            map.ShowsUserLocation = false;

            MKReverseGeocoder geo      = new MKReverseGeocoder(locationManager.Location.Coordinate);
            CLGeocoder        geocoder = new CLGeocoder();

            Task.Factory.StartNew(async() =>
            {
                var res = await geocoder.ReverseGeocodeLocationAsync(locationManager.Location);
                Console.WriteLine(res[0].AdministrativeArea);

                pais   = res[0].Country;
                ciudad = res[0].Locality;
            });

            // centro el mapa y pongo el zoom en la region
            mapCenter = new CLLocationCoordinate2D(locationManager.Location.Coordinate.Latitude,
                                                   locationManager.Location.Coordinate.Longitude);
            var mapRegion = MKCoordinateRegion.FromDistance(mapCenter, 2000, 2000);

            map.CenterCoordinate = mapCenter;
            map.Region           = mapRegion;
        }
        //als user gebruik maakt van de location button
        public void GetAddress()
        {
            var myVM = this.ViewModel as AddLocationViewModel;

            if (myVM != null)
            {
                //permissie vragen aan gebruiker voor locatie
                CLLocationManager locationManager = new CLLocationManager();
                locationManager.RequestWhenInUseAuthorization();

                CLLocation loc = locationManager.Location;
                ReverseGeocodeToConsoleAsync(loc);

                async void ReverseGeocodeToConsoleAsync(CLLocation location)
                {
                    var geoCoder   = new CLGeocoder();
                    var placemarks = await geoCoder.ReverseGeocodeLocationAsync(location);

                    txtCity.Text          = placemarks[0].PostalAddress.City;
                    myVM.Location.City    = placemarks[0].PostalAddress.City;
                    txtCountry.Text       = placemarks[0].PostalAddress.Country;
                    myVM.Location.Country = placemarks[0].PostalAddress.Country;
                    txtStreet.Text        = placemarks[0].PostalAddress.Street;
                    myVM.Location.Street  = placemarks[0].PostalAddress.Street;
                }
            }
        }
Esempio n. 6
0
        public async Task <CLPlacemark> ReverseGeocodeLocation(CLLocation location)
        {
            var geocoder = new CLGeocoder();

            var placemarks = await geocoder.ReverseGeocodeLocationAsync(location);

            return(placemarks?.FirstOrDefault());
        }
Esempio n. 7
0
        public static async Task <IEnumerable <Placemark> > GetPlacemarksAsync(double latitude, double longitude)
        {
            using (var geocoder = new CLGeocoder())
            {
                var addressList = await geocoder.ReverseGeocodeLocationAsync(new CLLocation(latitude, longitude));

                return(addressList?.ToPlacemarks());
            }
        }
Esempio n. 8
0
        public async Task <GeoAddress[]> GeocodeLocationAsync(double latitude, double longitude, string currentLanguage)
        {
            var geocoder = new CLGeocoder();

            var placemarks = await geocoder.ReverseGeocodeLocationAsync(new CLLocation(latitude, longitude));

            return(placemarks
                   .Select(ConvertPlacemarkToAddress)
                   .ToArray());
        }
        /// <summary>
        /// Retrieve addresses for position.
        /// </summary>
        /// <param name="position">Desired position (latitude and longitude)</param>
        /// <returns>Addresses of the desired position</returns>
        public async Task<IEnumerable<Address>> GetAddressesForPositionAsync(Position position, string mapKey = null)
        {
            if (position == null)
                throw new ArgumentNullException(nameof(position));

            using (var geocoder = new CLGeocoder())
            {
                var addressList = await geocoder.ReverseGeocodeLocationAsync(new CLLocation(position.Latitude, position.Longitude));
                return addressList.ToAddresses();
            }
        }
Esempio n. 10
0
        public async Task <LocationAddress> ReverseLocationAsync(double lat, double lng)
        {
            var geoCoder   = new CLGeocoder();
            var location   = new CLLocation(lat, lng);
            var placemarks = await geoCoder.ReverseGeocodeLocationAsync(location);

            var place = new LocationAddress();
            var pm    = placemarks[0];

            place.City = pm.AdministrativeArea;
            return(place);
        }
        async Task <string> ReverseGeocodeToConsoleAsync()
        {
            if (String.IsNullOrEmpty(CompanyAddressMapViewController.company_lat) || String.IsNullOrEmpty(CompanyAddressMapViewController.company_lng))
            {
                return(null);
            }
            double     lat      = Convert.ToDouble(CompanyAddressMapViewController.company_lat, CultureInfo.InvariantCulture);
            double     lng      = Convert.ToDouble(CompanyAddressMapViewController.company_lng, CultureInfo.InvariantCulture);
            CLLocation location = new CLLocation(lat, lng);
            var        geoCoder = new CLGeocoder();

            CLPlacemark[] placemarks = null;
            try
            {
                placemarks = await geoCoder.ReverseGeocodeLocationAsync(location);
            }
            catch
            {
                if (!methods.IsConnected())
                {
                    InvokeOnMainThread(() =>
                    {
                        NoConnectionViewController.view_controller_name = GetType().Name;
                        this.NavigationController.PushViewController(sb.InstantiateViewController(nameof(NoConnectionViewController)), false);
                        return;
                    });
                }
                return(null);
            }
            foreach (var placemark in placemarks)
            {
                //notationTemp = null;
                regionTemp             = null;
                indexTemp              = placemark.PostalCode;
                countryTemp            = placemark.Country;
                cityTemp               = placemark.SubAdministrativeArea;
                FullCompanyAddressTemp = placemark.Thoroughfare;
                if (placemark.SubThoroughfare != null)
                {
                    if (!placemark.SubThoroughfare.Contains(placemark.Thoroughfare))
                    {
                        FullCompanyAddressTemp += " " + placemark.SubThoroughfare;
                    }
                }


                break;

                //Console.WriteLine(placemark);
                //return placemark.Description;
            }
            return("");
        }
        /// <summary>
        /// Retrieve addresses for position.
        /// </summary>
        /// <param name="location">Desired position (latitude and longitude)</param>
        /// <returns>Addresses of the desired position</returns>
        public async Task <IEnumerable <Address> > GetAddressesForPositionAsync(Position location, string mapKey = null)
        {
            if (location == null)
            {
                return(null);
            }

            var geocoder    = new CLGeocoder();
            var addressList = await geocoder.ReverseGeocodeLocationAsync(new CLLocation(location.Latitude, location.Longitude));

            return(addressList.ToAddresses());
        }
Esempio n. 13
0
        public async Task <string> GetCityNameFromLocationAsync(LocationInfo location)
        {
            string city = string.Empty;

            using (var geocoder = new CLGeocoder())
            {
                var addresses = await geocoder.ReverseGeocodeLocationAsync(new CLLocation(location.Latitude, location.Longitude));

                city = addresses.FirstOrDefault()?.Locality;
            }

            return(city);
        }
Esempio n. 14
0
        public async Task <string> GetNameForLocation(double latitude, double longitude)
        {
            var coder = new CLGeocoder();

            var locations = await coder.ReverseGeocodeLocationAsync(new CLLocation
                                                                    (latitude, longitude));

            var name = locations?.FirstOrDefault()?.Name ?? "unknown";


            await AddCoffee(name, latitude, longitude);

            return(name);
        }
Esempio n. 15
0
        /// <summary>
        /// Gets the location address.
        /// </summary>
        /// <param name="latitude">Latitude.</param>
        /// <param name="longitude">Longitude.</param>
        public async Task <string> GetLocationAddress(double latitude, double longitude)
        {
            var placemarks = await _geocoder.ReverseGeocodeLocationAsync(new CLLocation(latitude, longitude));

            if (placemarks?.Length > 0)
            {
                var placemark = placemarks[0];

                return(string.Format("{0}, {1}, {2}, {3}",
                                     placemark.AddressDictionary["Street"],
                                     placemark.AddressDictionary["City"],
                                     placemark.AddressDictionary["State"],
                                     placemark.AddressDictionary["PostCodeExtension"]));
            }

            return(string.Empty);
        }
Esempio n. 16
0
        public static async Task <MapLocationFinderResult> FindLocationsAtAsync(CancellationToken ct, Geopoint queryPoint)
        {
            var locations = await _geocoder.ReverseGeocodeLocationAsync(new CLLocation(queryPoint.Position.Latitude, queryPoint.Position.Longitude));

            var mapLocations = locations.Select(loc =>
            {
                var point = new Geopoint(
                    new BasicGeoposition
                {
                    Latitude  = loc.Location.Coordinate.Latitude,
                    Longitude = loc.Location.Coordinate.Longitude,
                    Altitude  = loc.Location.Altitude
                }
                    );

                var address = new MapAddress(
                    buildingFloor: string.Empty,    // not supported
                    buildingRoom: string.Empty,     // not supported
                    buildingWing: string.Empty,     // not supported
                    buildingName: string.Empty,     // not supported
                    formattedAddress: string.Empty, // TODO
                    continent: null,                // not supported
                    country: loc.Country,
                    countryCode: loc.IsoCountryCode,
                    district: loc.SubAdministrativeArea, // TODO: Verify
                    neighborhood: loc.SubLocality,       // TODO: Verify
                    postCode: loc.PostalCode,
                    region: loc.AdministrativeArea,      // TODO: Verify
                    regionCode: null,                    // TODO: Verify
                    street: loc.Thoroughfare,            // TODO: Verify
                    streetNumber: loc.SubThoroughfare,
                    town: loc.Locality
                    );

                return(new MapLocation(point, address));
            })
                               .ToList()
                               .AsReadOnly();

            var status = MapLocationFinderStatus.Success; // TODO

            return(new MapLocationFinderResult(
                       locations: mapLocations,
                       status: status
                       ));
        }
Esempio n. 17
0
        public async Task <List <Event> > GetLocalEvents(CLLocation currentLocation)
        {
            var    geocoder   = new CLGeocoder();
            string Local      = null;
            var    placemarks = await geocoder.ReverseGeocodeLocationAsync(currentLocation);

            foreach (var placemark in placemarks)
            {
                Local = placemark.Locality;
            }
            var response = await _client.GetAsync("events/" + Local);

            using (var stream = await response.Content.ReadAsStreamAsync())
                using (var reader = new StreamReader(stream))
                    using (var json = new JsonTextReader(reader))
                    {
                        return(_serializer.Deserialize <List <Event> >(json));
                    }
        }
Esempio n. 18
0
        public async Task <Address> ReverseGeoCodeLatLonAsync(double lat, double lon)
        {
            var geocoder  = new CLGeocoder();
            var loc       = new CLLocation(lat, lon);
            var addresses = await geocoder.ReverseGeocodeLocationAsync(loc);

            if (addresses.Length > 0)
            {
                var place = new Address();
                var add   = addresses[0];
                place.City   = add.Locality;
                place.Plz    = add.PostalCode;
                place.Street = add.Name;

                return(place);
            }

            return(null);
        }
Esempio n. 19
0
        private async Task UpdateLocationString()
        {
            var result = default(string);

            if (IsLocationAccessible && CurrentLocation != Location.Empty)
            {
                var isConnected = await _reachabilityService.GetIsReachable();

                if (isConnected)
                {
                    var placemarks = default(CLPlacemark[]);

                    try
                    {
                        var location =
                            new CLLocation(
                                CurrentLocation.Latitude,
                                CurrentLocation.Longitude);
                        placemarks = await _geocoder
                                     .ReverseGeocodeLocationAsync(location);
                    }
                    catch (Exception ex)
                    {
                        _exceptionPolicy.Trace(ex, false);
                    }

                    if (placemarks != null)
                    {
                        var placemark = placemarks.FirstOrDefault();
                        if (placemark != null &&
                            placemark.Locality != null)
                        {
                            result = placemark.Locality;
                        }
                    }
                }
            }

            CurrentLocationString = result;
        }
Esempio n. 20
0
        /// <summary>
        /// Getes the street for a given location.
        /// </summary>
        /// <returns>The string for location.</returns>
        /// <param name="geoCoder">Geo coder.</param>
        /// <param name="location">Location.</param>
        public async static Task <string> GetStreetForLocation(CLGeocoder geoCoder, CLLocation location)
        {
            // Try to find a human readable location description.
            var street = string.Empty;

            try
            {
                var placemarks = await geoCoder.ReverseGeocodeLocationAsync(location);

                if (placemarks != null && placemarks.Length > 0)
                {
                    street = placemarks[0].Thoroughfare;
                }
            }
            catch (Exception ex)
            {
                // This can go wrong, especially on the Simulator.
                //Console.WriteLine("Geocoder error: " + ex);
                street = "(unknown)";
            }

            return(street);
        }
Esempio n. 21
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();
            var Localizador = await Geolocation.GetLocationAsync();

            double Latitud       = Localizador.Latitude;
            double Longitud      = Localizador.Longitude;
            var    Ubicacion     = new CLLocation(Latitud, Longitud);
            var    Georeferencia = new CLGeocoder();
            var    Datos         = await Georeferencia.ReverseGeocodeLocationAsync(Ubicacion);

            lblPais.Text       = Datos[0].Country;
            lblEstado.Text     = Datos[0].AdministrativeArea;
            lblCiudad.Text     = Datos[0].Locality;
            lblColonia.Text    = Datos[0].SubLocality;
            TvDescripcion.Text = Datos[0].Description;
            Mapa.MapType       = MKMapType.Hybrid;
            var Centrar = new CLLocationCoordinate2D(Latitud, Longitud);
            var Altura  = new MKCoordinateSpan(.003, .003);
            var Region  = new MKCoordinateRegion(Centrar, Altura);

            Mapa.SetRegion(Region, true);
        }
Esempio n. 22
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();
            await autorizacionCamara();

            ConfiguracionCamara();
            btnCapturar.TouchUpInside += async delegate
            {
                var salidadevideo = salidaImagen.ConnectionFromMediaType(AVMediaType.Video);
                var bufferdevideo = await salidaImagen.CaptureStillImageTaskAsync(salidadevideo);

                var datosImagen = AVCaptureStillImageOutput.JpegStillToNSData(bufferdevideo);

                arregloJpg = datosImagen.ToArray();
                string rutacarpeta = Environment.GetFolderPath
                                         (Environment.SpecialFolder.Personal);
                string resultado = "Foto";
                archivoLocal = resultado + ".jpg";
                ruta         = Path.Combine(rutacarpeta, archivoLocal);
                File.WriteAllBytes(ruta, arregloJpg);
                Imagen.Image = UIImage.FromFile(ruta);
            };
            btnRespaldar.TouchUpInside += async delegate
            {
                try
                {
                    CloudStorageAccount cuentaAlmacenamiento = CloudStorageAccount.Parse
                                                                   ("DefaultEndpointsProtocol=https;AccountName=almacenamientoxamarin;AccountKey=hX6T/p8IcOAF8RomLimw0fnLfkUC5CbnLOEn+6X5xLo3BxvOrmsUel0U2B4UtSK8cONvkBWUAFNJT+OR5tc3EA==");
                    CloudBlobClient    clienteBlob = cuentaAlmacenamiento.CreateCloudBlobClient();
                    CloudBlobContainer contenedor  = clienteBlob.GetContainerReference("imagenes");
                    CloudBlockBlob     recursoblob = contenedor.GetBlockBlobReference(archivoLocal);
                    await recursoblob.UploadFromFileAsync(ruta);

                    MessageBox("Guardado en", "Azure Storage - Blob");

                    CloudTableClient tableClient = cuentaAlmacenamiento.CreateCloudTableClient();

                    CloudTable table = tableClient.GetTableReference("Ubicaciones");

                    await table.CreateIfNotExistsAsync();

                    UbicacionEntity ubica = new UbicacionEntity(archivoLocal, Pais);
                    ubica.Latitud   = latitud;
                    ubica.Localidad = Ciudad;
                    ubica.Longitud  = longitud;

                    TableOperation insertar = TableOperation.Insert(ubica);
                    await table.ExecuteAsync(insertar);

                    MessageBox("Guardado en Azure", "Table NoSQL");
                }
                catch (StorageException ex)
                {
                    MessageBox("Error: ", ex.Message);
                }
            };

            #region "Mapas"

            locationManager = new CLLocationManager();
            locationManager.RequestWhenInUseAuthorization();
            Mapa.ShowsUserLocation = true;
            var locator  = CrossGeolocator.Current;
            var position = await
                           locator.GetPositionAsync(timeoutMilliseconds : 10000);

            Mapa.MapType = MKMapType.Hybrid;
            CLLocationCoordinate2D Centrar = new CLLocationCoordinate2D
                                                 (position.Latitude,
                                                 position.Longitude);
            MKCoordinateSpan   Altura = new MKCoordinateSpan(.002, .002);
            MKCoordinateRegion Region = new MKCoordinateRegion
                                            (Centrar, Altura);
            Mapa.SetRegion(Region, true);

            CLLocation Ubicacion = new CLLocation(position.Latitude, position.Longitude);

            CLGeocoder clg   = new CLGeocoder();
            var        Datos = await clg.ReverseGeocodeLocationAsync(Ubicacion);

            Pais     = Datos[0].Country;
            Ciudad   = Datos[0].Locality;
            latitud  = position.Latitude;
            longitud = position.Longitude;

            #endregion
        }
Esempio n. 23
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            path = Path.Combine(path, "thebase.db3");
            var conn = new SQLiteConnection(path);

            conn.CreateTable <Empleados>();

            Vista.Text = "";
            var fileOrDirectory = Directory.GetFiles
                                      (Environment.GetFolderPath
                                          (Environment.SpecialFolder.Personal));

            foreach (var entry in fileOrDirectory)
            {
                Vista.Text += entry + Environment.NewLine;
            }


            locationManager = new CLLocationManager();
            locationManager.RequestWhenInUseAuthorization();
            Mapa.ShowsUserLocation = true;
            var locator  = CrossGeolocator.Current;
            var position = await locator.GetPositionAsync(10000);

            var Ubicacion = new CLLocation(position.Latitude, position.Longitude);
            var clg       = new CLGeocoder();
            var Datos     = await clg.ReverseGeocodeLocationAsync(Ubicacion);

            var Pais   = Datos[0].Country;
            var Ciudad = Datos[0].Locality;

            MessageBox(Pais, Ciudad);
            Latitud  = position.Latitude;
            Longitud = position.Longitude;

            Mapa.MapType = MKMapType.HybridFlyover;
            var Centrar = new CLLocationCoordinate2D(Latitud, Longitud);
            var Altura  = new MKCoordinateSpan(.003, .003);
            var Region  = new MKCoordinateRegion(Centrar, Altura);

            Mapa.SetRegion(Region, true);



            btnBuscarXML.TouchUpInside += delegate
            {
                string rutaImagen;
                try
                {
                    int foliobusca = int.Parse(txtFolioB.Text);
                    var elementos  = from s in conn.Table
                                     <Empleados>()
                                     where s.Folio == foliobusca
                                     select s;
                    foreach (var fila in elementos)
                    {
                        txtFolio.Text  = fila.Folio.ToString();
                        txtNombre.Text = fila.Nombre;
                        txtEdad.Text   = fila.Edad.ToString();
                        txtPuesto.Text = fila.Puesto;
                        txtSueldo.Text = fila.Sueldo.ToString();
                        rutaImagen     = Path.Combine
                                             (Environment.GetFolderPath
                                                 (Environment.SpecialFolder.
                                                 Personal),
                                             txtFolioB.Text + ".jpg");
                        Imagen.Image = UIImage.FromFile(rutaImagen);

                        var RecibeCentrar = new CLLocationCoordinate2D
                                                (double.Parse(fila.Latitud), double.Parse(fila.Longitud));
                        var RecibeAltura = new MKCoordinateSpan(.002, .002);
                        var RecibeRegion = new MKCoordinateRegion
                                               (RecibeCentrar, RecibeAltura);
                        Mapa.SetRegion(RecibeRegion, true);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox("Estatus:", ex.Message);
                }
            };
            txtFolioB.ShouldReturn += (textField) =>
            {
                txtFolioB.ResignFirstResponder();
                return(true);
            };
        }
Esempio n. 24
0
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);

            path = Path.Combine(path, "thebase.db3");
            var conn = new SQLiteConnection(path);

            conn.CreateTable <Empleados>();

            Vista.Text = "";
            var fileOrDirectory = Directory.GetFiles
                                      (Environment.GetFolderPath
                                          (Environment.SpecialFolder.Personal));

            foreach (var entry in fileOrDirectory)
            {
                Vista.Text += entry + Environment.NewLine;
            }
            SeleccionadorImagen = new UIImagePickerController();
            SeleccionadorImagen.FinishedPickingMedia += SeleccionImagen;
            SeleccionadorImagen.Canceled             += ImagenCancelada;
            SeleccionadorImagen.AllowsEditing         = true;
            if (UIImagePickerController.IsSourceTypeAvailable
                    (UIImagePickerControllerSourceType.Camera))
            {
                SeleccionadorImagen.SourceType =
                    UIImagePickerControllerSourceType.Camera;
            }
            else
            {
                SeleccionadorImagen.SourceType =
                    UIImagePickerControllerSourceType.PhotoLibrary;
            }
            btnImagen.TouchUpInside += delegate
            {
                PresentViewController(SeleccionadorImagen, true, null);
            };

            locationManager = new CLLocationManager();
            locationManager.RequestWhenInUseAuthorization();
            Mapa.ShowsUserLocation = true;
            var locator  = CrossGeolocator.Current;
            var position = await locator.GetPositionAsync(10000);

            var Ubicacion = new CLLocation(position.Latitude, position.Longitude);
            var clg       = new CLGeocoder();
            var Datos     = await clg.ReverseGeocodeLocationAsync(Ubicacion);

            var Pais   = Datos[0].Country;
            var Ciudad = Datos[0].Locality;

            MessageBox(Pais, Ciudad);
            Latitud  = position.Latitude;
            Longitud = position.Longitude;

            Mapa.MapType = MKMapType.HybridFlyover;
            var Centrar = new CLLocationCoordinate2D(Latitud, Longitud);
            var Altura  = new MKCoordinateSpan(.003, .003);
            var Region  = new MKCoordinateRegion(Centrar, Altura);

            Mapa.SetRegion(Region, true);



            btnGuardarXML.TouchUpInside += delegate
            {
                try
                {
                    var Insertar = new Empleados();
                    Insertar.Folio     = int.Parse(txtFolio.Text);
                    Insertar.Nombre    = txtNombre.Text;
                    Insertar.Edad      = int.Parse(txtEdad.Text);
                    Insertar.Puesto    = txtPuesto.Text;
                    Insertar.Sueldo    = double.Parse(txtSueldo.Text);
                    Insertar.Foto      = txtFolio.Text + ".jpg";
                    Insertar.Latitud   = Latitud.ToString();
                    Insertar.Longitud  = Longitud.ToString();
                    Insertar.Pais      = Pais.ToString();
                    Insertar.Localidad = Ciudad.ToString();
                    conn.Insert(Insertar);
                    txtFolio.Text  = "";
                    txtNombre.Text = "";
                    txtEdad.Text   = "";
                    txtPuesto.Text = "";
                    txtSueldo.Text = "";
                    MessageBox("Guardado Correctamente", "SQLite");
                }
                catch (Exception ex)
                {
                    MessageBox("Estatus:", ex.Message);
                }
            };
        }
Esempio n. 25
0
		/// <summary>
		/// Getes the street for a given location.
		/// </summary>
		/// <returns>The string for location.</returns>
		/// <param name="geoCoder">Geo coder.</param>
		/// <param name="location">Location.</param>
		public async static Task<string> GetStreetForLocation(CLGeocoder geoCoder, CLLocation location)
		{
			// Try to find a human readable location description.
			var street = string.Empty;
			try
			{
				var placemarks = await geoCoder.ReverseGeocodeLocationAsync(location);
				if(placemarks != null && placemarks.Length > 0)
				{
					street = placemarks[0].Thoroughfare;
				}
			}
			catch(Exception ex)
			{
				// This can go wrong, especially on the Simulator.
				//Console.WriteLine("Geocoder error: " + ex);
				street = "(unknown)";
			}

			return street;
		}
Esempio n. 26
0
		public async Task<CLPlacemark> ReverseGeocodeLocation (CLLocation location)
		{
			var geocoder = new CLGeocoder ();

			var placemarks = await geocoder.ReverseGeocodeLocationAsync (location);

			return placemarks?.FirstOrDefault ();
		}