Skip to content

Instantly share code, notes, and snippets.

@numa08
Created August 26, 2012 14:51
Show Gist options
  • Save numa08/3480661 to your computer and use it in GitHub Desktop.
Save numa08/3480661 to your computer and use it in GitHub Desktop.
Rxを使って位置情報を得る #もう泣かないC# ref: http://qiita.com/items/5ba8ab5c0a931f88f483
var geoWatcher = new GeoCoordinateWatcher();
Observable.FromEvent<GeoPositionChangedEventArgs<GeoCoordinate>>(geoWatcher, "PositionChanged").ObserveOnDispatcher()
//位置情報だけクレ
.Select(ev => ev.EventArgs.Position.Location)
//場所が変わると呼ばれる
.Subscribe(location => {
//位置情報を使って何かやる
onLocationChanged(location);
//一回だけで良いわ
geoWatcher.Stop(); });
geoWatcher.Start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment