public async Task<GeoLocation> GetCurrentLocation() { if (_curLocation == null) { _locationRecieved = new TaskCompletionSource<Android.Locations.Location>(); Criteria locationCriteria = new Criteria(); locationCriteria.Accuracy = Accuracy.Coarse; locationCriteria.PowerRequirement = Power.Low; string locationProvider = Manager.GetBestProvider(locationCriteria, true); if (locationProvider != null && Manager.IsProviderEnabled(locationProvider)) { Manager.RequestLocationUpdates(locationProvider, 2000, 1, Activity); Android.Locations.Location loc = await _locationRecieved.Task.TimeoutAfter(1000); if (loc != null) { _curLocation = new GeoLocation(loc.Latitude, loc.Longitude); } } } return _curLocation; }
public bool GoToLocation(GeoLocation location) { try { var urlString = String.Format("{0}ll={1}",_baseUrl,location); var uri = new Uri(urlString); var url = new NSUrl(uri.GetComponents(UriComponents.HttpRequestUrl, UriFormat.UriEscaped)); return GoToMap (url); } catch (Exception e) { _logger.Log (e); return false; } }
public bool GoToLocation(GeoLocation location) { var geoUri = Android.Net.Uri.Parse (String.Format ("geo:{0}", location)); return GoToMap (geoUri); }