private async Task Refresh() { lblDistance.SetText("searching..."); lblVenue.SetText(""); // Get current location var locationService = new LocationService(); var coords = await locationService.GetGeoCoordinatesAsync(); RefreshMap(new CLLocationCoordinate2D(coords.Latitude, coords.Longitude)); // Find some coffee venues var foursquareService = new FoursquareService(); var results = await foursquareService.GetVenues("coffee", coords); // Determine the closest venue Venue closest = null; if (results.Venues.Count > 0) { var ordered = from v in results.Venues orderby v.Address.Distance select v; closest = ordered.FirstOrDefault(); if (closest != null) { lblDistance.SetText(closest.Address.Distance + " meters away"); lblVenue.SetText(closest.Name); AddMapPin(new CLLocationCoordinate2D(closest.Address.Latitude, closest.Address.Longitude)); } else { lblDistance.SetText("None :("); lblVenue.SetText(""); } } else { lblDistance.SetText("None :("); lblVenue.SetText(""); } }
IEnumerator Start() { // First, check if user has location service enabled if (!Input.location.isEnabledByUser) { yield break; } // Start service before querying location Input.location.Start(); // Wait until service initializes int maxWait = 20; while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0) { yield return(new WaitForSeconds(1)); maxWait--; } // Service didn't initialize in 20 seconds if (maxWait < 1) { print("Location Request : Timed out"); yield break; } // Connection has failed if (Input.location.status == LocationServiceStatus.Failed) { print("Unable to determine device location"); yield break; } else { print("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp); FoursquareService foursquare = new FoursquareService(); StartCoroutine(foursquare.callExploreApi(Input.location.lastData.latitude.ToString(), Input.location.lastData.longitude.ToString())); } }
private async Task MoveMapToRegion(Plugin.Geolocator.Abstractions.Position position) { var center = new Xamarin.Forms.Maps.Position(position.Latitude, position.Longitude); var distance = Distance.FromMiles(1.0); var mapSpan = MapSpan.FromCenterAndRadius(center, distance); var pin = new Pin { Type = PinType.SavedPin, Position = center, Label = "Home" }; map.Pins.Clear(); map.Pins.Add(pin); map.MoveToRegion(mapSpan); var venues = await FoursquareService.GetVenues(position.Latitude, position.Longitude); _viewModel.SetVenues(venues); }
public void ProcessRequest(HttpContext context) { SocialConnection sc = new SocialConnection(); SocialAccessToken accessToken = null; switch (context.Request.QueryString[0]) { case "foursquare": FoursquareService fsqs = new FoursquareService(); accessToken = fsqs.GetAccessToken(context.Request.QueryString["code"]); Igloo.SharpSquare.Entities.User fsqUser = fsqs.GetProfile(accessToken.Token); sc.OauthToken = accessToken.Token; sc.ReferenceID = fsqUser.id; sc.ServiceID = SocialServiceType.Foursquare; sc.UserID = 1; break; case "twitter": SocialServices.TwitterService tws = new SocialServices.TwitterService(); accessToken = tws.GetAccessToken(context.Request.QueryString["oauth_token"], context.Request.QueryString["oauth_verifier"]); TwitterUser twitterUser = tws.GetProfile(accessToken.Token, accessToken.TokenSecret); sc.OauthToken = accessToken.Token; sc.OauthVerifier = accessToken.TokenSecret; sc.ServiceID = SocialServiceType.Twitter; sc.UserID = 1; sc.ReferenceID = twitterUser.Id.ToString(); break; } SocialServiceManager scm = new SocialServiceManager(); scm.AddConnection(sc); context.Response.Redirect("/services?added=" + context.Request.QueryString[0]); }
public CategoryService(FoursquareService service) { _service = service; FetchMainCategories(); }
public string GetFoursquareRedirectUri() { FoursquareService fsqs = new FoursquareService(); return fsqs.GetAuthenticationUri().AbsoluteUri; }