title: Simple Google map display on location information page in ASP.NET MVC
body: <p>The company which work is being done for has many terminals or locations all over the united states.  The terminal managers have access to admin pages that let them enter details specifically for their location including their street address, city, state, zip, phone number, email addresses, etc.  When this is displayed on the public facing pages, the map needs to be displayed in a block next to the address.  The address is being concatenated into something that can be searched on google maps, and this needs to be displayed.  Unfortunately, after a few days of working on this, the tutorials and technical documentation seems to always lead me to dead ends, that result in some issue.  The latest code that I have is an attempt to put the code necessary into an HTML helper function with the code below:</p>
  
  <pre><code>    public static MvcHtmlString GoogleMapFor(this HtmlHelper htmlHelper, string address, int width = 450, int height = 250)
      {
          var url = new UrlHelper(htmlHelper.ViewContext.RequestContext);
  
          bool isSecure = HttpContext.Current.Request.IsSecureConnection;
          const string GOOGLE_MAP_DOMAIN = "maps.google.com";
          const string GOOGLE_MAP_ACTION = "/maps/embed/v1/place";
          string googleApiKey = ConfigurationManager.AppSettings["GoogleMapAPIKey"];
  
          var tag = new TagBuilder("iframe");
          tag.MergeAttribute("width", width.ToString());
          tag.MergeAttribute("height", width.ToString());
          tag.MergeAttribute("style", "border: 0");
          tag.MergeAttribute("frameborder", "0");
          tag.MergeAttribute("scrolling", "no");
          tag.MergeAttribute("marginheight", "0");
          tag.MergeAttribute("marginwidth", "0");
  
          var googleMapKeys = new Dictionary&lt;string, string&gt;
          {
              {"key", googleApiKey},
              {"q", address},
          };
  
          string googleMapUrl = String.Format (
                                                  @"{0}://{1}{2}?{3}", 
                                                  isSecure ? "https" : "http",
                                                  GOOGLE_MAP_DOMAIN,
                                                  GOOGLE_MAP_ACTION,
                                                  googleMapKeys.Select(x =&gt; String.Format("{0}{1}{2}", url.Encode(x.Key), "=",  url.Encode(x.Value))).Join("&amp;")
                                              );
  
          tag.MergeAttribute("src", googleMapUrl);
          return MvcHtmlString.Create(tag.ToString());
      }
  </code></pre>
  
  <p>on the front end view, I use it with the following code:</p>
  
  <pre><code>&lt;div class="sub-form" style="width: 49%; border: 1px solid #4b6c9e; border-left:none; height: 6.5em; float: left;"&gt;
      &lt;dl class="dl-horizontal"&gt;
          &lt;dd style="float: left; width: 100%; padding: 0;"&gt;
              Location
          &lt;/dd&gt;
          &lt;dt&gt;
              @Html.GoogleMapFor("1601 Harbor Bay Parkway Alameda CA 94502");    
          &lt;/dt&gt;
      &lt;/dl&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>First of all, the google api key registration page asks for the domain that the requests will be coming from.  Which, is going to be difficult if not impossible as all the terminals can use custom URLS and often do.  These are set up by the local managers and I, as just a developer, have no control over this or even knowledge of what domain individual locations will use.</p>
  
  <p>Currently, I'm running the site locally, and do not have a SSL Cert, and most of the public facing servers do not have an SSL Cert.  The latest issue I've run into is that the embeded map doesn't seem to support non-secure pages, since I'm getting this error on the front end instead of the map that I want to see:</p>
  
  <pre><code>The Google Maps API server rejected your request. Requests to this API must be over SSL.
  </code></pre>
  
  <p>When I haven't been able to find solutions through regular searching techniques, I've spent most of the morning this morning browsing through the google-maps tagged posts here on SO.  Is there a simple implementation of just grabbing an address and displaying an embedded Google map without all the overhead and requirements that I can't comply with.  Or should I ditch Google, and try to work with MapQuest (does this even exist anymore?), Yahoo Maps or Bing?  Any suggestions would be appreciated. </p>