Пример #1
0
 public void TestGoogleGeoCodingResponse()
 {
     SpotInfo sinfo = new SpotInfo();
     sinfo.Address = "1310 South White Oak Drive , Apt 714 , Waukegan";
     Geocoder geo = new Geocoder();
     GeoResult result = geo.GetGeoResult(sinfo);
     Assert.AreEqual(result.Status, GeoResultStatus.OK);
 }
Пример #2
0
 public void TestCurrentLocation()
 {
     SpotInfo sinfo = new SpotInfo(42.370525571796215, -87.85941852461143);
     //sinfo.LatLng = new SpotLatLng(42.370525571796215, -87.85941852461143);
     sinfo.Sensor = true;
     Geocoder geo = new Geocoder();
     GeoResult geoResult = geo.GetGeoResult(sinfo);
     Assert.IsTrue(geoResult.Results.Count > 0);
 }
        public ActionResult Index(FourSquareVenueViewModel viewModel)
        {
            viewModel.FourSquareVenueList.Clear();
            SpotInfo sinfo = new SpotInfo();
            sinfo.Address = viewModel.FourSquareVenueEntity.LocationName.Trim();
            Geocoder geo = new Geocoder();
            GeoResult result = geo.GetGeoResult(sinfo);
            if(result.Status == GeoResultStatus.OK){
                string authToken = ConfigurationManager.AppSettings["authToken"].ToString();
                string lat = result.Results[0].Geometry.Location.Lat.ToString();
                string lang = result.Results[0].Geometry.Location.Lng.ToString();
                string latlang = lat + "," + lang;
                var recommentedVenues = NetSquare.VenueExplore(latlang, "", "", "", "10000", "", viewModel.FourSquareVenueEntity.Query, "", "", authToken);
                foreach (var place in recommentedVenues.places)
                {
                    var recommendedValues = ((List<NetSquare.FourSquareRecommendedVenues.recommends>)place.Value);
                    foreach (var recommendedValue in recommendedValues)
                    {
                        viewModel.FourSquareVenueList.Add(new NetSquare.FourSquareVenue
                        {
                            url = recommendedValue.venue.url,
                            name = recommendedValue.venue.name,
                            id = recommendedValue.venue.id,
                            location = new NetSquare.FourSquareLocation{
                                Lat = recommendedValue.venue.location.Lat,
                                Long = recommendedValue.venue.location.Long
                            },
                            stats = new NetSquare.FourSquareStats
                            {
                                checkinsCount = recommendedValue.venue.stats.checkinsCount,
                                usersCount = recommendedValue.venue.stats.usersCount,
                            }
                        });
                    }
                }
            }

            if (viewModel.FourSquareVenueList.Count > 0)
            {
                var fourSquareHelper = new FourSquareVenueHelper();
                viewModel.FourSquareVenueForChart = fourSquareHelper.GetViewModel(viewModel.FourSquareVenueList);
            }
            return View(viewModel);
        }