Esempio n. 1
0
        private async Task <GeoCoordinate> ShowMyCurrentLocationOnTheMap()
        {
            // Get my current location.
            Geolocator  myGeolocator  = new Geolocator();
            Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();

            myGeocoordinate = myGeoposition.Coordinate;

            wayPoints.Add(new GeoCoordinate(myGeocoordinate.Latitude, myGeocoordinate.Longitude));
            //GeoCoordinate myxGeocoordinate = new GeoCoordinate(47.6785619, -122.1311156);

            myGeoCoordinate =
                CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);

            // Make my current location the center of the Map.
            this.mapPostItinerary.Center    = myGeoCoordinate;
            this.mapPostItinerary.ZoomLevel = 16;


            // Create a MapOverlay to contain the circle.
            myCurentLocationOverlay = MarkerDraw.DrawMapMarker(myGeoCoordinate);

            // Create a MapLayer to contain the MapOverlay.
            myLocationLayer = new MapLayer();
            myLocationLayer.Add(myCurentLocationOverlay);

            // Add the MapLayer to the Map.
            mapPostItinerary.Layers.Add(myLocationLayer);

            return(myGeoCoordinate);
        }
Esempio n. 2
0
        /*For see you location on the map*/
        private async void ShowMyLocationOnTheMap()
        {
            // Get my current location.
            Geolocator  myGeolocator  = new Geolocator();
            Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();

            Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
            GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);

            // Make my current location the center of the Map.
            //MessageBox.Show("Latitude" + myGeoCoordinate.Latitude+ "Longitud: " + myGeoCoordinate.Longitude + "Altitud:"+myGeoCoordinate.Altitude);
            place = myGeocoordinate.ToGeoCoordinate().ToString();
            this.mapWithMyLocation.Center    = myGeoCoordinate;
            this.mapWithMyLocation.ZoomLevel = 13;
            // Create a small circle to mark the current location.
            Ellipse myCircle = new Ellipse();

            myCircle.Fill    = new SolidColorBrush(Colors.Blue);
            myCircle.Height  = 20;
            myCircle.Width   = 20;
            myCircle.Opacity = 50;
            // Create a MapOverlay to contain the circle.
            MapOverlay myLocationOverlay = new MapOverlay();

            myLocationOverlay.Content        = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate  = myGeoCoordinate;
            // Create a MapLayer to contain the MapOverlay.
            MapLayer myLocationLayer = new MapLayer();

            myLocationLayer.Add(myLocationOverlay);
            // Add the MapLayer to the Map.
            mapWithMyLocation.Layers.Add(myLocationLayer);
        }
Esempio n. 3
0
        /// <summary>
        /// Se encarga de obtener los FeedXively en un radio de 1km.
        /// </summary>
        private async void ObetenerFeedXively()
        {
            /// Que esten muchas condiciones anidadas es porque cada llamado se demora su tiempo, puede
            /// que se pierda la conexión en algun momento.
            if (HayConexiónInternet())
            {
                Geolocator  myGeolocator  = new Geolocator();
                Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();

                if (HayConexiónInternet())
                {
                    Double la = Convert.ToDouble(myGeoposition.Coordinate.Latitude);
                    Double lo = Convert.ToDouble(myGeoposition.Coordinate.Longitude);

                    Geocoordinate myGeocoordinate = myGeoposition.Coordinate;
                    GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);

                    if (HayConexiónInternet())
                    {
                        WSSemanticSearchSoapClient WS = new WSSemanticSearchSoapClient();
                        WS.RetornarMapaLugarDatapointsAsync(la, lo, paramConsulta, DateTime.Now.AddSeconds(tSegundosAntes), DateTime.Now, "Español", rangoConsulta);
                        WS.RetornarMapaLugarDatapointsCompleted += ob_RetornarMapaLugarDatapointsCompleted;
                    }
                }
            }
        }
        private async Task AddCurrentLocationToMap()
        {
            var myGeolocator  = new Geolocator();
            var myGeoposition = await myGeolocator.GetGeopositionAsync();

            var myGeocoordinate = myGeoposition.Coordinate;
            var myGeoCoordinate =
                CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);
            var myCircle = new Ellipse();

            myCircle.Fill    = new SolidColorBrush(Colors.Blue);
            myCircle.Height  = 20;
            myCircle.Width   = 20;
            myCircle.Opacity = 50;

            var myLocationOverlay = new MapOverlay();

            myLocationOverlay.Content        = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate  = myGeoCoordinate;

            // Create a MapLayer to contain the MapOverlay.
            var myLocationLayer = new MapLayer();

            myLocationLayer.Add(myLocationOverlay);

            _nativeMap.Layers.Add(myLocationLayer);
        }
Esempio n. 5
0
        //private void ReturnFromPlaceToMain_Click(object sender, RoutedEventArgs e)
        //{
        //    NavigationService.Navigate(new Uri("/Main.xaml", UriKind.Relative));
        //}
        /*For see you location on the map*/
        private async void ShowMyLocationOnTheMap(string[] strArr)
        {
            // Get my current location.
            Geolocator  myGeolocator  = new Geolocator();
            Geoposition myGeoposition = await myGeolocator.GetGeopositionAsync();

            Geocoordinate myGeocoordinate = myGeoposition.Coordinate;

            GeoCoordinate myGeoCoordinate = CoordinateConverter.ConvertGeocoordinate(myGeocoordinate);

            // Make my current location the center of the Map.
            try
            {
                if (!(strArr[0] == null) && !(strArr[2] == null))
                {
                    myGeoCoordinate.Latitude  = Convert.ToDouble(strArr[0].Replace('.', ','));
                    myGeoCoordinate.Longitude = Convert.ToDouble(strArr[2].Replace('.', ','));
                }
            }
            catch
            {
                MessageBox.Show("No se puede ubicar el lugar.", "¡Aviso!", MessageBoxButton.OK);
            }

            this.mapPlaceRecommendation.Center    = myGeoCoordinate;
            this.mapPlaceRecommendation.ZoomLevel = 13;
            // Create a small circle to mark the current location.
            Ellipse myCircle = new Ellipse();

            myCircle.Fill    = new SolidColorBrush(Colors.Blue);
            myCircle.Height  = 20;
            myCircle.Width   = 20;
            myCircle.Opacity = 50;
            // Create a MapOverlay to contain the circle.
            MapOverlay myLocationOverlay = new MapOverlay();

            myLocationOverlay.Content        = myCircle;
            myLocationOverlay.PositionOrigin = new Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate  = myGeoCoordinate;
            // Create a MapLayer to contain the MapOverlay.
            MapLayer myLocationLayer = new MapLayer();

            myLocationLayer.Add(myLocationOverlay);
            // Add the MapLayer to the Map.
            mapPlaceRecommendation.Layers.Add(myLocationLayer);
        }
        //string ParseGoogleResponse(string data)
        //{
        //    var xmlElm = XElement.Parse(data);
        //    var status = (from elm in xmlElm.Descendants() where elm.Name == "status" select elm).FirstOrDefault();
        //    if (status.Value.ToLower() == "ok")
        //    {
        //        var res = (from elm in xmlElm.Descendants() where elm.Name == "formatted_address" select elm).FirstOrDefault();
        //        return res.Value;
        //    }
        //    return null;
        //}

        private async Task <GeoCoordinate> GetCurrentLocation()
        {
            Geolocator geoLocator = new Geolocator()
            {
                DesiredAccuracy = PositionAccuracy.High
            };

            try
            {
                var position = await geoLocator.GetGeopositionAsync(TimeSpan.FromHours(24), TimeSpan.FromSeconds(5));

                return(CoordinateConverter.ConvertGeocoordinate(position.Coordinate));
            }
            catch (Exception) { }

            Dispatcher.BeginInvoke(() =>
            {
                OSHelper.ShowToast(AppResources.TextID18);
            });

            return(null);
        }