当前位置: 首页>>代码示例>>C#>>正文


C# GeoCoordinateWatcher类代码示例

本文整理汇总了C#中GeoCoordinateWatcher的典型用法代码示例。如果您正苦于以下问题:C# GeoCoordinateWatcher类的具体用法?C# GeoCoordinateWatcher怎么用?C# GeoCoordinateWatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GeoCoordinateWatcher类属于命名空间,在下文中一共展示了GeoCoordinateWatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RouteDetailsPanoramaPage

        public RouteDetailsPanoramaPage()
        {
            InitializeComponent();

            pins = new List<Pushpin>();

            var clusterer = new PushpinClusterer(map1, pins, this.Resources["ClusterTemplate"] as DataTemplate);

            SystemTray.SetIsVisible(this, true);

            if (watcher == null)
            {
                //---get the highest accuracy---
                watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
                {
                    //---the minimum distance (in meters) to travel before the next
                    // location update---
                    MovementThreshold = 10
                };

                //---event to fire when a new position is obtained---
                watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);

                //---event to fire when there is a status change in the location
                // service API---
                watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
                watcher.Start();

                map1.Center = new GeoCoordinate(58.383333, 26.716667);
                map1.ZoomLevel = 15;
                map1.Mode = new MyMapMode();
            }
        }
开发者ID:madisp,项目名称:Omnibuss,代码行数:33,代码来源:RouteDetailsPanoramaPage.xaml.cs

示例2: OnNavigatedTo

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var photoResult = PhoneHelpers.GetApplicationState<PhotoResult>("PhotoResult");

            if (this.watcher == null)
            {
                // Use high accuracy.
                this.watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);

                this.watcher.MovementThreshold = 20;

                // Use MovementThreshold to ignore noise in the signal.
                this.watcher.StatusChanged += this.GeoCoordinateWatcherStatusChanged;
            }

            this.watcher.Start();

            if ((this.ViewModel != null) && (photoResult != null))
            {
                this.ViewModel.LoadPhoto(photoResult);
            }
            else
            {
                this.NavigationService.GoBack();
            }
        }
开发者ID:ayant,项目名称:Discount-aggregator,代码行数:26,代码来源:UploadPhotoPage.xaml.cs

示例3: add

        public add()
        {
            InitializeComponent();

            GeoCoordinateWatcher my_watcher = new GeoCoordinateWatcher();

            var my_position = my_watcher.Position;

            // set a default value, if we canot get the current location,
            // the we'll default to Redmond, WA

            double latitude = 47.674;
            double longitude = -122.12;

            if (!my_position.Location.IsUnknown)
            {
                latitude = my_position.Location.Latitude;
                longitude = my_position.Location.Longitude;
            }


            myTerraService.TerraServiceSoapClient client = new myTerraService.TerraServiceSoapClient();
            client.ConvertLonLatPtToNearestPlaceCompleted += new EventHandler<myTerraService.ConvertLonLatPtToNearestPlaceCompletedEventArgs>(client_ConvertLonLatPtToNearestPlaceCompleted);
            client.ConvertLonLatPtToNearestPlaceAsync(new myTerraService.LonLatPt() { Lat = latitude, Lon = longitude });
        
        }
开发者ID:enyblock,项目名称:enyblock_note,代码行数:26,代码来源:add.xaml.cs

示例4: GeoLocationService

 public GeoLocationService()
 {
     _watcher = new GeoCoordinateWatcher();
     _watcher.StatusChanged += Watcher_StatusChanged;
     _watcher.PositionChanged += Watcher_PositionChanged;
     _watcher.Start();
 }
开发者ID:AlexanderGrant1,项目名称:PropertyCross,代码行数:7,代码来源:GeoLocationService.cs

示例5: MainPage

 public MainPage()
 {
     if (NetworkInterface.GetIsNetworkAvailable())
     {
         InitializeComponent();
         if (watcher == null)
         {
             watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
             watcher.MovementThreshold = 10.0f;
             watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
         }
         geolist = new List<GeoCoordinate>();
         loc = new List<Local>();
         stateWatcher();
         GetLocales();
         navi = true;
     }
     else
     {
         InitializeComponent();
         string a = "ADVERTENCIA: Sin Conexión";
         string b = "Esta Aplicación requiere de conexión a internet, ya que consulta información en línea.";
         MessageBox.Show(a+"\n"+b+"\nGracias");
     }
 }
开发者ID:Asfiroth,项目名称:MovistApp,代码行数:25,代码来源:MainPage.xaml.cs

示例6: OnNavigatedTo

        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            gcw = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
            gcw.PositionChanged += gcw_PositionChanged;
            gcw.StatusChanged += gcw_StatusChanged;

            map.ColorMode = Microsoft.Phone.Maps.Controls.MapColorMode.Light;
            map.CartographicMode = Microsoft.Phone.Maps.Controls.MapCartographicMode.Road;
            map.LandmarksEnabled = true;
            map.PedestrianFeaturesEnabled = true;
            map.ZoomLevel = 17;

            if (!App.IsInBackground)
            {
                txtCurrentSpeed.Foreground = new SolidColorBrush(Colors.Black);
                overlay.Content = txtCurrentSpeed;

                routeQuery.TravelMode = Microsoft.Phone.Maps.Services.TravelMode.Walking;
                routeQuery.QueryCompleted += rq_QueryCompleted;

                MapLayer currentSpeedLayer = new MapLayer();
                currentSpeedLayer.Add(overlay);
                map.Layers.Add(currentSpeedLayer);
                map.Layers.Add(historicalReadingsLayer);
                map.MapElements.Add(polyline);
            }

            base.OnNavigatedTo(e);
        }
开发者ID:WindowsPhone-8-TrainingKit,项目名称:HOL-RunningTrackerApplication,代码行数:29,代码来源:MainPage.xaml.cs

示例7: MainPage

        public MainPage()
        {
            InitializeComponent();

            _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
            _watcher.MovementThreshold = 20;
            _watcher.StatusChanged += (sender, args) =>
                {
                    if (args.Status == GeoPositionStatus.Ready)
                    {
                        try
                        {
                            GeoCoordinate coordinates = _watcher.Position.Location;
                            DevCenterAds.Longitude = coordinates.Longitude;
                            DevCenterAds.Latitude = coordinates.Latitude;
                        }
                        finally
                        {
                            _watcher.Stop();
                        }
                    }
                };
            _watcher.Start();

            LayoutUpdated += OnLayoutUpdated;
        }
开发者ID:mikkoviitala,项目名称:battlelogmobile,代码行数:26,代码来源:MainPage.xaml.cs

示例8: MainPage

        // Constructor
        public MainPage()
        {
            InitializeComponent();
            if (watcher == null)
            {
                //Get the highest accuracy.
                watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
                {
                    //The minimum distance (in meters) to travel before the next location update.
                    MovementThreshold = 10
                };
                //Event to fire when a new position is obtained.
                watcher.PositionChanged += new
                EventHandler<GeoPositionChangedEventArgs
                <GeoCoordinate>>(watcher_PositionChanged);

                //Event to fire when there is a status change in the location service API.
                watcher.StatusChanged += new
                EventHandler<GeoPositionStatusChangedEventArgs>
                (watcher_StatusChanged);
                watcher.Start();

            }
            // position change code start
            watcher.PositionChanged += this.watcher_PositionChanged;
            watcher.StatusChanged += this.watcher_StatusChanged;
            watcher.Start();
            // position chane code stop
        }
开发者ID:27kunal,项目名称:Pocket_Security,代码行数:30,代码来源:MainPage.xaml.cs

示例9: GeoLocationManager

 public GeoLocationManager()
 {
     // using high accuracy;
     _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
     _watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(WatcherStatusChanged);
     _watcher.PositionChanged += new System.EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(WatcherPositionChanged);
 }
开发者ID:douglaszuniga,项目名称:Reportero-Digital,代码行数:7,代码来源:GeoLocationManager.cs

示例10: MapDetail

        // bool MapSet = false;
        public MapDetail()
        {
            InitializeComponent();

            //sets up GeoCoordinateWatcher
            if (watcher == null)
            {
                //---get the highest accuracy---
                watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
                {
                    //---the minimum distance (in meters) to travel before the next
                    // location update---
                    MovementThreshold = 10
                };

                //---event to fire when a new position is obtained---
                watcher.PositionChanged += new
                EventHandler<GeoPositionChangedEventArgs
                <GeoCoordinate>>(watcher_PositionChanged);

                //---event to fire when there is a status change in the location
                // service API---
                watcher.StatusChanged += new
                EventHandler<GeoPositionStatusChangedEventArgs>
                (watcher_StatusChanged);
                watcher.Start();
            }

            setMap();
        }
开发者ID:VandyApps,项目名称:dining-windows,代码行数:31,代码来源:MapDetail.xaml.cs

示例11: JustRun

        public JustRun()
        {
            InitializeComponent();
            running = false;

            Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode =
            Microsoft.Phone.Shell.IdleDetectionMode.Disabled;

            // The watcher variable was previously declared as type GeoCoordinateWatcher.
            if (watcher == null)
            {
                watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); // using high accuracy
                //watcher.MovementThreshold = 1; // use MovementThreshold to ignore noise in the signal

                watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
                watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
                watcher.Start();

                Globals.lat = watcher.Position.Location.Latitude;
                Globals.lon = watcher.Position.Location.Longitude;
            }

            Globals.dist = 0.0;

            if (Globals.usingMeters)
            {
                tbUnits.Text = "km";
                tbV.Text = "km/h";
            }
            else
            {
                tbUnits.Text = "mi";
                tbV.Text = "mph";
            }
        }
开发者ID:frank44,项目名称:Just-Run,代码行数:35,代码来源:JustRun.xaml.cs

示例12: MapPage

        public MapPage()
        {
            InitializeComponent();
            // Define event handlers
            NotificationClient.Current.NotificationReceived += new EventHandler(getNotification);
            NotificationClient.Current.UriUpdated += new EventHandler(setUri);

            // Reinitialize the GeoCoordinateWatcher
            watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
            watcher.MovementThreshold = 5;//distance in metres

            // Add event handlers for StatusChanged and PositionChanged events
            watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
            watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);

            // Start data acquisition
            watcher.Start();

            if (firstRun)
            {
                firstRun = false;
                // Ask for next check-in point
                DisplayInfoText("Retrieving first checkpoint", 10);
                QueryCidLocationWithWait(10);
                // Ask for number of checkpoints
                send(GlobalVars.serveraddr + "get_n?token=" + GlobalVars.token, SendType.GetN);
            }
        }
开发者ID:bdunlay,项目名称:geoscav,代码行数:28,代码来源:MapPage.xaml.cs

示例13: CustomMapControls

        /// <summary>
        /// Creates a new CustomMapControls class object using default images.
        /// </summary>
        /// <param name="map">Map object on which actions are to be performed. </param>
        public CustomMapControls(Map map)
        {
            try
            {
                this._map = map;
                _map.Children.Add(ImageLayer);
                _homeImage.Source = new BitmapImage(new Uri("/CustomMapLibrary;component/Resources/home.png", UriKind.Relative));
                _pinImage.Source = new BitmapImage(new Uri("/CustomMapLibrary;component/Resources/pin.png", UriKind.Relative));

                _pinImage.Tap += new EventHandler<GestureEventArgs>(pinImage_Tap);
                _map.Tap += new EventHandler<GestureEventArgs>(map_Tap);
                _map.Hold += new EventHandler<GestureEventArgs>(map_Hold);
                _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
                _watcher.MovementThreshold = 20;
                _watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
                _watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
                _watcher.Start(true);

                //Forward Button Press Event from Popup Window 
                _popupWindow.btnDetails.Click += new RoutedEventHandler(btnDetails_Click);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error: " + e.Message + "\n" + e.Data + "\n" + e.StackTrace);
            }
        }
开发者ID:pankajc-optimus,项目名称:windows-lib,代码行数:30,代码来源:CustomMapControls.cs

示例14: ConcertDetails

 public ConcertDetails()
 {
     InitializeComponent();
     GeoCoordinateWatcher geoWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
     geoWatcher.StatusChanged += geoWatcher_StatusChanged; 
     geoWatcher.PositionChanged += geoWatcher_PositionChanged;
     geoWatcher.Start();
     map.ZoomLevel = 15;
     if (PhoneApplicationService.Current.State["connected"].Equals(1))
     {
         Uri imageUriConnected = new Uri("/Images/ic_connected.png", UriKind.Relative);
         BitmapImage imageBitmapConnected = new BitmapImage(imageUriConnected);
         imgConnected.Source = imageBitmapConnected;
     }
     else
     {
         Uri imageUriNotConnected = new Uri("/Images/ic_not_connected.png", UriKind.Relative);
         BitmapImage imageBitmapNotConnected = new BitmapImage(imageUriNotConnected);
         imgConnected.Source = imageBitmapNotConnected;
     }
     Concert concert = (Concert)PhoneApplicationService.Current.State["Concert"];
     Uri imageUri = new Uri(concert.image, UriKind.Absolute);
     BitmapImage imageBitmap = new BitmapImage(imageUri);
     imgConcert.Source = imageBitmap;
     textBeginDate.Text = concert.start_datetime;
     textEndDate.Text = concert.end_datetime;
     textLocation.Text = concert.location;
     textNbSeets.Text = "Number of seats : " + concert.nb_seats;
     textTitle.Text = concert.name_concert;
     
     geoWatcher = new GeoCoordinateWatcher();
     geoWatcher.StatusChanged += geoWatcher_StatusChanged;
     geoWatcher.Start();
 }
开发者ID:rcrozon,项目名称:PartyProject,代码行数:34,代码来源:ConcertDetails.xaml.cs

示例15: Initialize

        public void Initialize(Action<GeoPositionStatus> del)
        {
            if (IsInitialized)
            {
                _watcher.Start();
                return;
            }

            // instantiate the GeoCoordinateWatcher
            _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);

            // Create an observable sequence of GeoPositionStatusChanged events.
            var locationStatusEventAsObservable = Observable.FromEvent<GeoPositionStatusChangedEventArgs>(
                ev => _watcher.StatusChanged += ev,
                ev => _watcher.StatusChanged -= ev);

            // For simplicity, create a stream of GeoPositionStatus objects from the stream of
            // GeoPositionStatusChangedEventArgs objects
            var statusFromEventArgs = from ev in locationStatusEventAsObservable
                                      select ev.EventArgs.Status;

            // Subscribe to the Observable  stream. InvokeStatusChanged will be called each time
            // a new GeoPositionStatus object arrives in the stream.
            statusFromEventArgs.Subscribe(status => del(status));

            // Start the GeoCoordinateWatcher
            _watcher.Start();

            IsInitialized = true;
        }
开发者ID:ayls,项目名称:EatMyDust,代码行数:30,代码来源:PhoneLocationService.cs


注:本文中的GeoCoordinateWatcher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。