title: Get Id from Array inside function
body: <p>I have an problem with an for loop in an LeafletJs map, for some reason i can't get it give me the correct Id from a array, instead it give me the last id on all clickevent's. Outside the <code>$.get()</code> the Id is displayed correct. But inside i just get the last in the Array. Are it possible to Exend the option to get an custom one ore are there other ways to do it.</p>
  
  <pre><code>for (var i = 0; i &lt; myColumnDefs.length; i++) {
        var obj = myColumnDefs[i];
       // obj.id = i;
        var latitude = obj.GisLatitude.toFixed(5);
        var longitude = obj.GisLongitude.toFixed(5);
  
      //The correct id
        console.log(obj.Id);
  
        var m = L.marker([latitude, longitude], { icon: greenIcon }).on('click', function (e) {
          var markeren = this;
          debugger;
  
          $.get(ol.url('~/Map/MapContent/'), {id: m.id }, function(data) {
            L.popup()
          .setLatLng(markeren.getLatLng())
          .setContent(data)
          .openOn(map);
          });
        }).addTo(map);
        m.id = obj.Id;
        console.log('Latitude: '+latitude + ' - Longitude: ' + longitude);
      }
  </code></pre>