Created
June 25, 2012 06:11
-
-
Save anuith/2986933 to your computer and use it in GitHub Desktop.
Windows Phone Hackathon : Bing Map Sample - Code - Button_Go_Click
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 Button_Go_Click(object sender, RoutedEventArgs e) | |
| { | |
| if (watcher != null) | |
| { | |
| watcher.Stop(); | |
| } | |
| double lat, lon; | |
| if(!double.TryParse(TextBox_Lat.Text, out lat)) { | |
| MessageBox.Show( | |
| "latitude must be number.", | |
| "invalid number", MessageBoxButton.OK); | |
| return; | |
| } | |
| if (!double.TryParse(TextBox_Lon.Text, out lon)) { | |
| MessageBox.Show( | |
| "longitude must be number.", "invalid number", | |
| MessageBoxButton.OK); | |
| return; | |
| } | |
| if (lat > 90 || lat < -90) | |
| { | |
| MessageBox.Show( | |
| "latitude must be between -90 to 90.", | |
| "invalid number", | |
| MessageBoxButton.OK); | |
| return; | |
| } | |
| if (lon > 180 || lon < -180) | |
| { | |
| MessageBox.Show( | |
| "longitude must be between -180 to 180.", | |
| "invalid number", | |
| MessageBoxButton.OK); | |
| return; | |
| } | |
| GeoCoordinate location = new GeoCoordinate(lat, lon); | |
| Map_Main.SetView(location, 15); | |
| PushPin_Main.Location = location; | |
| PushPin_Main.Visibility = System.Windows.Visibility.Visible; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment