Exemple #1
0
        public MapQuestLocationData ReturnLocations(int id)
        {
            var property   = _context.Property.Include("Address").FirstOrDefault(p => p.PropertyId == id);
            var key        = Keys.MapQuestAPIKey;
            var lat        = property.Address.Latitude;
            var lng        = property.Address.Longitude;
            var requestUrl = $"http://www.mapquestapi.com/search/v2/radius?key={key}&maxMatches=10&origin={lat},{lng}&radius=15&units=wmin";
            var result     = new WebClient().DownloadString(requestUrl);
            MapQuestLocationData placesData = JsonConvert.DeserializeObject <MapQuestLocationData>(result);

            return(placesData);
        }
Exemple #2
0
        public List <PointOfInterest> GetListOfPointsOfInterest(int id)
        {
            List <PointOfInterest> pointsOfInterest = new List <PointOfInterest>();
            MapQuestLocationData   mapQuestJson     = ReturnLocations(id);
            var result = mapQuestJson.searchResults;

            foreach (var item in result)
            {
                PointOfInterest point = new PointOfInterest();
                point.Address        = item.fields.address;
                point.Name           = item.name;
                point.PhoneNumber    = item.fields.phone;
                point.TypeOfBusiness = item.fields.group_sic_code_name;
                pointsOfInterest.Add(point);
            }
            return(pointsOfInterest);
        }