Пример #1
0
        public async void setPosition(double latitude, double longitude)
        {
            Uri url = new Uri("http://produccion.rl2012alc.com/api/index.php/setPosition");

            objetoslistas.getByCoord paquete = new objetoslistas.getByCoord();
            paquete.latitude  = latitude;
            paquete.longitude = longitude;
            string respuesta = await metodosJson.jsonPOST(url, paquete);
        }
Пример #2
0
        //METODOS DE LOCALIZACION Y MAPA
        //busca la ubicacion, situa al usuario y al mapa, e inicia el seguimiento
        private async void iniciamapa()
        {
            geolocator.DesiredAccuracyInMeters = DesiredAccuracyInMeters;
            geolocator.DesiredAccuracy         = PositionAccuracy.High;
            try
            {
                prog.IsVisible = true;
                prog.Text      = "Obteniendo localización";
                IAsyncOperation <Geoposition> locationTask = null;
                try
                {
                    locationTask = geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(15));
                    Geoposition   position        = await locationTask;
                    Geocoordinate myGeocoordinate = position.Coordinate;
                    GeoCoordinate myGeoCoordinate = ConvertGeocoordinate(myGeocoordinate);
                    centro    = myGeoCoordinate;
                    prog.Text = "Localización obtenida";
                    this.mapacentral.Center = myGeoCoordinate;
                    usuariocordx            = position.Coordinate.Latitude;
                    usuariocordy            = position.Coordinate.Longitude;
                    setPosition(position.Coordinate.Latitude, position.Coordinate.Longitude);

                    ReverseGeocodeQuery query = new ReverseGeocodeQuery();
                    query.GeoCoordinate   = new GeoCoordinate(position.Coordinate.Latitude, position.Coordinate.Longitude);
                    query.QueryCompleted += ReverseGeocodeQuery_QueryCompleted;
                    query.QueryAsync();

                    localespincho(position.Coordinate.Latitude, position.Coordinate.Longitude);
                    Uri url = new Uri("http://produccion.rl2012alc.com/api/index.php/setPosition ");
                    objetoslistas.getByCoord paquete = new objetoslistas.getByCoord();
                    paquete.latitude  = position.Coordinate.Latitude;
                    paquete.longitude = position.Coordinate.Longitude;
                    string respuesta = await metodosJson.jsonPOST(url, paquete);

                    if (listapinchos.Count > 0)
                    {
                        checklocal();
                    }
                }
                finally
                {
                    if (locationTask != null)
                    {
                        if (locationTask.Status == AsyncStatus.Started)
                        {
                            locationTask.Cancel();
                        }
                        locationTask.Close();
                    }
                }
            }
            catch (Exception)
            {
                // the app does not have the right capability or the location master switch is off
                MessageBoxResult result = MessageBox.Show("Location  is disabled in phone settings", "ERROR", MessageBoxButton.OK);
            }
        }