title: Pass MSSQL table values to javascript
body: <p>I'm trying to make a website with asp.net mvc 4 &amp; EF6 where I want to pass values from MSSQL table to javascript. So far everything is working fine except if I pass <code>Latitude</code> &amp; <code>Longitude</code> values for <code>google-map-api</code> function, map doesn't show up in my view. I used <code>Html.HiddenFor</code> helper to pass the value from <code>&lt;span&gt;</code>. Here are my codes,</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public ActionResult BranchDetails(int BrId)
      {
          Branch branchDetails = abdb.Branches.Find(BrId);
          return View(branchDetails);
      }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;script&gt;
      function initialize() {
          var marker;
          var LatTag = document.getElementById("Lat");
          var Lat = LatTag.getElementsByTagName("span");
          var LngTag = document.getElementById("Lng");
          var Lng = LngTag.getElementsByTagName("span");
          var mapProp = {
              center: new google.maps.LatLng(LatTag, LngTag),
              zoom: 18,
              mapTypeId: google.maps.MapTypeId.ROADMAP
          };
          var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
  
          marker = new google.maps.Marker({
              position: new google.maps.LatLng(Lat, Lng),
              animation: google.maps.Animation.BOUNCE
          });
  
          marker.setMap(map);
      }
      google.maps.event.addDomListener(window, 'load', initialize);
  &lt;/script&gt;
  
  &lt;body&gt;
      &lt;div class="container well" style="min-width: 100%; padding-right: 5px;"&gt;        
          &lt;div id="googleMap"&gt;&lt;/div&gt;
          &lt;span id="Lat"&gt;@Html.HiddenFor(model =&gt; model.Latitude)&lt;/span&gt;
          &lt;span id="Lng"&gt;@Html.HiddenFor(model =&gt; model.Longitude)&lt;/span&gt;
          &lt;h4&gt;&lt;b&gt;@Html.DisplayFor(model =&gt; model.Title)&lt;/b&gt;&lt;/h4&gt;
          &lt;p&gt;&lt;strong&gt;Address:&lt;/strong&gt; @Html.DisplayFor(model =&gt; model.Address)&lt;/p&gt;
          &lt;p&gt;&lt;strong&gt;Contact No. :&lt;/strong&gt; @Html.DisplayFor(model =&gt; model.ContactNo)&lt;/p&gt;
          &lt;p&gt;&lt;strong&gt;Contact Person(s):&lt;/strong&gt; @Html.DisplayFor(model =&gt; model.ContactPerson)&lt;/p&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Point to be noted that my <code>Longitude</code> &amp; <code>Latitude</code> fields in MSSQL are set in <code>varchar</code> mode. I'm not sure if its causing the problem but just felt needed to inform. How can I solve this problem? Need this help badly. Tnx.</p>