Created
August 26, 2012 14:51
-
-
Save numa08/3480661 to your computer and use it in GitHub Desktop.
Rxを使って位置情報を得る #もう泣かないC# ref: http://qiita.com/items/5ba8ab5c0a931f88f483
This file contains 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
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