/**
         * Visualizza la posizione attuale del dispositivo.
         */
        private void ShowLocation()
        {
            UserLocationMarker marker = (UserLocationMarker)this.FindName("deviceMarker");

            marker.GeoCoordinate = currentLocation;
            marker.Visibility    = Visibility.Visible;
        }
Exemple #2
0
        private void marker_Loaded(object sender, RoutedEventArgs e)
        {
            UserLocationMarker marker = (UserLocationMarker)this.FindName("marker");

            marker.GeoCoordinate = position.Coordinate.ToGeoCoordinate();
            marker.Visibility    = Visibility.Visible;
        }
        void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
        {
            Dispatcher.BeginInvoke(() =>
            {
                Geocoordinate myGeocoordinate = args.Position.Coordinate;
                myMap.SetView(myGeocoordinate.ToGeoCoordinate(), 16, MapAnimationKind.Linear);


                UserLocationMarker newPin = (UserLocationMarker)this.FindName("UserLocationMarker");
                newPin.GeoCoordinate      = myGeocoordinate.ToGeoCoordinate();
            });
        }
Exemple #4
0
        private void AddUserPosition(GeoCoordinate position)
        {
            UserLocationMarker Marker = new UserLocationMarker();

            Marker.GeoCoordinate = position;

            MapOverlay myLocationOverlay = new MapOverlay();

            myLocationOverlay.Content        = Marker;
            myLocationOverlay.PositionOrigin = new System.Windows.Point(0.5, 0.5);
            myLocationOverlay.GeoCoordinate  = position;

            userLocationLayer = new MapLayer();
            userLocationLayer.Add(myLocationOverlay);
            MyMap.Layers.Add(userLocationLayer);
        }
Exemple #5
0
        private void ToForgeChildren()
        {
            if (children == null)
            {
                children = MapExtensions.GetChildren(myMap);

                marker          = children.FirstOrDefault(x => x.GetType() == typeof(UserLocationMarker)) as UserLocationMarker;
                mapItemsControl = children.FirstOrDefault(x => x.GetType() == typeof(MapItemsControl)) as MapItemsControl;
            }

            marker.GeoCoordinate = position.Coordinate.ToGeoCoordinate();

            if (pushpins.Count != 0)
            {
                mapItemsControl.ItemsSource = pushpins;
            }
        }
Exemple #6
0
        private async void ToggleLocation(object sender, EventArgs e)
        {
            Geolocator geo = new Geolocator();

            geo.DesiredAccuracy = PositionAccuracy.High;
            Geoposition position = null;

            // Se intenta ubicar la posición de nuestro teléfono
            try
            {
                position = await geo.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10));
            }
            catch (UnauthorizedAccessException)
            {
                MessageBox.Show("Ubicación está desactivada en tu dispositivo");
            }

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                try
                {
                    MyCoordinate = new GeoCoordinate(position.Coordinate.Latitude, position.Coordinate.Longitude);
                    myMap.SetView(MyCoordinate, 15);
                    var children = MapExtensions.GetChildren(map);
                    var ob       = children.Where(x => x.GetType() == typeof(UserLocationMarker)).FirstOrDefault();
                    UserLocationMarker marker = (UserLocationMarker)ob;

                    marker.GeoCoordinate = coordinate;
                    marker.Visibility    = System.Windows.Visibility.Visible;
                }
                catch (Exception)
                {
                    //      MessageBox.Show("No podemos obtener lugares cercanos a tu locacíon ,verifica tu conexión a datos");
                }
            });

            // Se mueve el centro del mapa hacia nuestra ubicación
            this.map.Center.Latitude  = position.Coordinate.Latitude;
            this.map.Center.Longitude = position.Coordinate.Longitude;
            this.map.ZoomLevel        = 15;
        }
        // Sample code for building a localized ApplicationBar
        //private void BuildLocalizedApplicationBar()
        //{
        //    // Set the page's ApplicationBar to a new instance of ApplicationBar.
        //    ApplicationBar = new ApplicationBar();

        //    // Create a new button and set the text value to the localized string from AppResources.
        //    ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
        //    appBarButton.Text = AppResources.AppBarButtonText;
        //    ApplicationBar.Buttons.Add(appBarButton);

        //    // Create a new menu item with the localized string from AppResources.
        //    ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
        //    ApplicationBar.MenuItems.Add(appBarMenuItem);
        //}

        private async void mapControl_Loaded(object sender, RoutedEventArgs e)
        {
            status.Text = "querying for current location...";

            Geolocator  locator     = new Geolocator();
            Geoposition geoPosition = await locator.GetGeopositionAsync();

            GeoCoordinate coordinate = geoPosition.Coordinate.ToGeoCoordinate();

            mapControl.Center    = coordinate;
            mapControl.ZoomLevel = 10;

            position.Text = string.Format("Latitude: {0}\nLongitude: {1}\n",
                                          FormatCoordinate(coordinate.Latitude, 'N', 'S'),
                                          FormatCoordinate(coordinate.Longitude, 'E', 'W'));

            marker = new UserLocationMarker();
            marker.GeoCoordinate = coordinate;
            MapExtensions.GetChildren(mapControl).Add(marker);

            status.Text += "complete";
        }