O'Reilly logo

Xamarin Blueprints by Michael Williams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling location updates

Our next step is to build the MapPageViewModel; this view model will contain the IGeolocator we just built. We will also be listening for location updates from the observable sequence and processing latitude and longitude values to gather address details.

Let's begin with the constructor:

public MapPageViewModel (INavigationService navigation, IGeolocator geolocator, Func<Action, ICommand> commandFactory, IGeocodingWebServiceController geocodingWebServiceController) : base (navigation) { _geolocator = geolocator; _geocodingWebServiceController = geocodingWebServiceController; _nearestAddressCommand = commandFactory(() => FindNearestSite()); _geolocationCommand = commandFactory(() => { if (_geolocationUpdating) { geolocator.Stop(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required