title: Callstack overflow on JSON .each
body: <p>I have a list of JSON objects that I loop through and then (using the jQuery Gmap plugin found <a href="http://code.google.com/p/jquery-ui-map/" rel="nofollow">here</a>) create markers for that object and add it to the map.</p>
  
  <p>Problem is that in each browser I'm getting callstack overflow messages:</p>
  
  <blockquote>
    <p>Uncaught RangeError: Maximum call stack size exceede</p>
  </blockquote>
  
  <p>in Chrome, and</p>
  
  <blockquote>
    <p>Too much recursion</p>
  </blockquote>
  
  <p>in Firefox.</p>
  
  <p>I have NO idea why or how to fix it.</p>
  
  <p>This is my code:</p>
  
  <pre><code>$('#map_canvas').gmap().bind('init', function (evt, map) {
          var webMethod = '&lt;%= NavigationHelper.GetFullUrl("Components/Services/storelocatorservice.asmx/GetStoresByAddress") %&gt;';
          var webParam = '{ "address": "Vaartkom 31/9 3000 Leuven", "language": "&lt;%= Sitecore.Context.Language.CultureInfo.TwoLetterISOLanguageName %&gt;", "radius": "15" }';
  
          $.ajax({
              type: "POST",
              url: webMethod,
              data: webParam,
              contentType: "application/json; charset=utf-8",
              dataType: "json",
              success: function (msg) {
                  //$('#map_canvas').gmap('set', 'MarkerClusterer', new MarkerClusterer(map));
                  addMarkers($.parseJSON(msg.d));
              }
          });
  });
  
  function addMarkers(json) {
          $.each(json, function (i, m) {
              $('#map_canvas').gmap('addMarker', {
                  'title': m.Name,
                  'position': new google.maps.LatLng(m.Lat, m.Long),
                  'name': m.Name,
                  'zipcode': m.ZipCode,
                  'id': m.LocationId,
                  'bounds': true
              }).click(function () {
                  $('#map_canvas').gmap('openInfoWindow', {
                      'content': '&lt;h3&gt;' + m.Name + '&lt;/h3&gt;&lt;p&gt;' + m.ZipCode + '&lt;/p&gt;&lt;a onclick="getDirections(\'' + m.Id + '\')"&gt;Route&lt;/a&gt;'
                  }, this);
              });
          });
  }
  </code></pre>
  
  <p>Any help is greatly appreciated!</p>