<commit_before>
$(document).ready(function() {
  $('.akvo_map').each(function() {
    var mapId = $(this).attr('id');
    var mapElement = document.getElementById(mapId);
    var mapOpts = window[mapId];
    var objectId = mapOpts.objectId;


    var googleMap = {
      canvas: mapElement,
      options: {
        zoom: mapOpts.zoom,
        center: new google.maps.LatLng(mapOpts.Lat, mapOpts.Lng),
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        scrollwheel: false,
        streetViewControl: false
      },
      load: function() {
        var map = new google.maps.Map(this.canvas, this.options);
        var marker = new google.maps.Marker({
          icon: '/rsr/media/core/img/blueMarker.png',
          map: map,
          position: this.options.center,
          clickable: false
        });
      }
    };
    googleMap.load();

    var akvoMap = {
      resourceURL: 'http://akvo.dev/api/v1/project_location/?format=jsonp&project=' + objectId + '&callback=?',

      load: function() {
        $.getJSON(this.resourceURL, function(data) {
          console.log(data.objects);
          $.each(data.objects, function(i, location) {
            console.log(location.city);
          });
        });

      }
    };
    akvoMap.load();

  });
});

/*

$(document).ready(function() {
  $('.akvo_map').each(function() {
    var mapElement = $(this).get();
    var mapId = $(this).attr('id');
    var opts = window[mapId];

    var options =  {<commit_msg>Maps works with multiple items<commit_after>
$(document).ready(function() {
  $('.akvo_map').each(function() {
    var mapId = $(this).attr('id');
    var mapElement = document.getElementById(mapId);
    var mapOpts = window[mapId];
    var objectId = mapOpts.objectId;


    var options = {
      zoom: mapOpts.zoom,
      center: new google.maps.LatLng(mapOpts.Lat, mapOpts.Lng),
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      scrollwheel: false,
      streetViewControl: false
      };

    var map = new google.maps.Map(mapElement, options);

  

    // var googleMap = {
    //   canvas: mapElement,
    //   options: {
    //     zoom: mapOpts.zoom,
    //     center: new google.maps.LatLng(mapOpts.Lat, mapOpts.Lng),
    //     mapTypeId: google.maps.MapTypeId.ROADMAP,
    //     scrollwheel: false,
    //     streetViewControl: false
    //   },
    //   load: function() {
    //     var map = new google.maps.Map(this.canvas, this.options);
    //     var marker = new google.maps.Marker({
    //       icon: '/rsr/media/core/img/blueMarker.png',
    //       map: map,
    //       position: this.options.center,
    //       clickable: false
    //     });
    //   }
    // };
    // googleMap.load();

    var akvoMap = {
      // resourceURL: 'http://akvo.dev/api/v1/project_location/?format=jsonp&project=' + objectId + '&callback=?',
      resourceURL: 'http://akvo.dev/api/v1/project/' + objectId + '/?format=json&depth=1&callback=?',

      load: function(callback) {
        $.getJSON(this.resourceURL, function(data) {
          var items = [];
          var title = data.title;
          $.each(data.locations, function(i, location) {
            items.push({
              'project': location.project,
              'latitude': location.latitude,
              'longitude': location.longitude,
              'primary': location.primary,
              'city': location.city
            });
          });
          callback(items);
        });
      }
    };

    akvoMap.load(function(locations){
      $.each(locations, function(index, location){
        console.log(location.city);
        var marker = new google.maps.Marker({
          icon: '/rsr/media/core/img/blueMarker.png',
          map: map,
          position: new google.maps.LatLng(location.latitude, location.longitude),
          clickable: false
        });
      });
    });

  });
});

/*

$(document).ready(function() {
  $('.akvo_map').each(function() {
    var mapElement = $(this).get();
    var mapId = $(this).attr('id');
    var opts = window[mapId];

    var options =  {
{'fraction_non_alphanumeric': 0.1605821410952146, 'fraction_numerical': 0.000986679822397632, 'mean_word_length': 2.0907012195121952, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '917324', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1273, 'n_words': 222}