Exemplo n.º 1
0
        /// <summary>
        /// Gets the retailer map page for a particular zip and mile range
        /// </summary>
        /// <param name="zip">The zip of the user, on which to center the map</param>
        /// <param name="range">The range in miles to find retailers within</param>
        /// <returns>The retailer map view</returns>
        // GET: RetailerMap
        public async Task <ActionResult> Index(string zip = "", int range = 50)
        {
            // If zip is passed, get coords for zip
            if (zip != "")
            {
                try
                {
                    var googleMapsClient = new GoogleMapsClient();
                    userLocation = await googleMapsClient.GeocodeAddress(zip);
                }
                catch
                {
                    userLocation = new LatLng(43, -86);
                }
            }

            ViewBag.Location = userLocation;

            // Pass filter terms back to view
            ViewBag.Zip   = zip;
            ViewBag.Range = range;

            // Zoom is based on search range
            ViewBag.Zoom          = GoogleMapsClient.RadiusToZoom(range);
            ViewBag.GoogleMapsUrl = GoogleMapsClient.baseUrl + "js?key=" + GoogleMapsClient.apiKey + "&callback=initialMap";
            return(View());
        }