Created
June 25, 2012 06:10
-
-
Save anuith/2986930 to your computer and use it in GitHub Desktop.
Windows Phone Hackathon : Bing Map Sample - Code - Watcher Events (continued from https://gist.github.com/2986924 )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e) { | |
| Deployment.Current.Dispatcher.BeginInvoke(() => LocationChanged(e)); | |
| } | |
| private void LocationChanged(GeoPositionChangedEventArgs<GeoCoordinate> e) { | |
| GeoCoordinate location = e.Position.Location; | |
| Map_Main.SetView(location, 15); | |
| PushPin_Main.Location = location; | |
| PushPin_Main.Visibility = System.Windows.Visibility.Visible; | |
| ApplicationBarIconButton ApplicationBarButton_FindMe = | |
| ApplicationBar.Buttons[0] as ApplicationBarIconButton; | |
| ApplicationBarButton_FindMe.IsEnabled = true; | |
| } | |
| private void watcher_StatusChanged( | |
| object sender, GeoPositionStatusChangedEventArgs e) { | |
| Deployment.Current.Dispatcher.BeginInvoke(() => LocationStatusChanged(e)); | |
| } | |
| private void LocationStatusChanged(GeoPositionStatusChangedEventArgs e) { | |
| ApplicationBarIconButton ApplicationBarButton_FindMe = | |
| ApplicationBar.Buttons[0] as ApplicationBarIconButton; | |
| switch (e.Status) { | |
| case GeoPositionStatus.Disabled: | |
| // The location service is disabled or unsupported. | |
| // Alert the user | |
| TextBlock_Status.Text = "location service in not available"; | |
| ApplicationBarButton_FindMe.IsEnabled = false; | |
| break; | |
| case GeoPositionStatus.Initializing: | |
| // The location service is initializing. | |
| // Disable the Start Location button | |
| TextBlock_Status.Text = "initializing"; | |
| break; | |
| case GeoPositionStatus.NoData: | |
| // The location service is working, but it cannot get location data | |
| // Alert the user and enable the Stop Location button | |
| TextBlock_Status.Text = "no data found"; | |
| PushPin_Main.Visibility = Visibility.Collapsed; | |
| ApplicationBarButton_FindMe.IsEnabled = false; | |
| break; | |
| case GeoPositionStatus.Ready: | |
| // The location service is working and is receiving location data | |
| // Show the current position and enable the Stop Location button | |
| TextBlock_Status.Text = "found you"; | |
| PushPin_Main.Visibility = Visibility.Visible; | |
| ApplicationBarButton_FindMe.IsEnabled = true; | |
| break; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment