void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
        {
            Dispatcher.BeginInvoke(() =>
            {
                //LatitudeTextBlock.Text = args.Position.Coordinate.Latitude.ToString("0.00000000");
                //LongitudeTextBlock.Text = args.Position.Coordinate.Longitude.ToString("0.00000000");

                GeoCoordinate currentCoordinate = new GeoCoordinate(args.Position.Coordinate.Latitude,
                                                                    args.Position.Coordinate.Longitude);
                currCoordinate = currentCoordinate;

                MainMap.SetView(currentCoordinate, MainMap.ZoomLevel);

                HeadingPath.Visibility    = Visibility.Visible;
                SecretTestPath.Visibility = Visibility.Visible;

                GeoCoordinate diamondCoordinate = new GeoCoordinate(StaticViewModel.MapViewModel.currentPlace.Latitude,
                                                                    StaticViewModel.MapViewModel.currentPlace.Longitude);

                if (StaticMethod.Distance(currentCoordinate, diamondCoordinate) <= 0.1)
                {
                    DiamondControl tempDiamondControl = diamondOverlay.Content as DiamondControl;
                    tempDiamondControl.ChangeColor();

                    CollectGrid.Visibility = Visibility.Visible;
                }
                else
                {
                    CollectGrid.Visibility = Visibility.Collapsed;
                }
            });
        }
 private void MainMap_OnCenterChanged(object sender, MapCenterChangedEventArgs e)
 {
     if (geolocator.LocationStatus == PositionStatus.Ready)
     {
         if (StaticMethod.Distance(currCoordinate, MainMap.Center) > 0.2)
         {
             HeadingPath.Visibility    = Visibility.Collapsed;
             SecretTestPath.Visibility = Visibility.Collapsed;
         }
         else
         {
             HeadingPath.Visibility    = Visibility.Visible;
             SecretTestPath.Visibility = Visibility.Visible;
         }
     }
 }
Exemplo n.º 3
0
        private async Task AddToCollection()
        {
            StaticData._stationCollection = new ObservableCollection <StationTotal>();
            UTMConverter  utmConverter = new UTMConverter();
            MessageDialog msg          = new MessageDialog("Location Service is not available!", "Error");

            try
            {
                var pos = await _geolocator.GetGeopositionAsync();

                if (pos != null)
                {
                    Location            location = new Location(pos.Coordinate.Latitude, pos.Coordinate.Longitude);
                    LocationPointWithId a        = new LocationPointWithId();
                    a.latitude  = pos.Coordinate.Latitude;
                    a.longitude = pos.Coordinate.Longitude;
                    LocationPointWithId temp = new LocationPointWithId();

                    foreach (StationTotal b in StaticData._stationTotal)
                    {
                        utmConverter.ToLatLon(b.latitude, b.longitude, 48, 0);
                        temp.latitude  = utmConverter.Latitude;
                        temp.longitude = utmConverter.Longitude;

                        if (StaticMethod.Distance(a, temp) < StaticData.defaultDistance)
                        {
                            StaticData._stationCollection.Add(b);
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                MessageDialog messageDialog = new MessageDialog("Error: " + exception.Message);
                messageDialog.ShowAsync();
                //return;
            }
        }
Exemplo n.º 4
0
        private async Task AddToCollectionWithCustomLocation(Location location)
        {
            StaticData._stationCollection = new ObservableCollection <StationTotal>();
            UTMConverter utmConverter = new UTMConverter();

            LocationPointWithId a = new LocationPointWithId();

            a.latitude  = location.Latitude;
            a.longitude = location.Longitude;

            LocationPointWithId temp = new LocationPointWithId();

            foreach (StationTotal b in StaticData._stationTotal)
            {
                utmConverter.ToLatLon(b.latitude, b.longitude, 48, 0);
                temp.latitude  = utmConverter.Latitude;
                temp.longitude = utmConverter.Longitude;

                if (StaticMethod.Distance(a, temp) < StaticData.defaultDistance)
                {
                    StaticData._stationCollection.Add(b);
                }
            }
        }