Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
		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;
			}
		}
Exemplo n.º 3
0
		public bool GoToLocation(GeoLocation location)
		{
			var geoUri = Android.Net.Uri.Parse (String.Format ("geo:{0}", location));
			return GoToMap (geoUri);
		}