private GeoCoordinate GetMyLocation() { #if REAL_WP7 IGeoPositionWatcher<GeoCoordinate> watcher; watcher = new System.Device.Location.GeoCoordinateWatcher(); // Do not suppress prompt, and wait 1000 milliseconds to start. watcher.TryStart(false, TimeSpan.FromMilliseconds(1000)); GeoCoordinate geoCenter = watcher.Position.Location; watcher.Stop(); return geoCenter; #endif #if VIRTUAL_WP7 GeoCoordinate geoCenter = new GeoCoordinate(32.114022, 34.803593); return geoCenter; #endif }
private void GPScheckbox_Checked(object sender, RoutedEventArgs e) { location = System.String.Empty; #if REAL_WP7 IGeoPositionWatcher<GeoCoordinate> watcher; watcher = new System.Device.Location.GeoCoordinateWatcher(); // Do not suppress prompt, and wait 1000 milliseconds to start. watcher.TryStart(false, TimeSpan.FromMilliseconds(1000)); GeoCoordinate coord = watcher.Position.Location; if (coord.IsUnknown != true) { location = coord.ToString(); watcher.Stop(); } else { location = null; } }