index.js
// create marker, infoWindow, add button for each call
create marker, infoWindow, add button for each call
create marker infoWindow add button for each call
function createMarker(event) {
  var pos = {lat: event.latitude, lng: event.longitude};
  var contentStr = '<div id="content">' +
    '<p><b>' + event.artists + ' @ ' + event.city + ', ' + event.region + '</b></p>' +
    '<p>' + event.formatted_datetime + '</p>' +
    '<p>' + event.name + '</p>' +
    '<button id="add-cal">Add to Calendar</button>' +
    '</div>'
  var marker = new google.maps.Marker({
    position: pos,
    animation: google.maps.Animation.DROP,
    map: map
  })
  var infoWin = new google.maps.InfoWindow ({
    content: contentStr,
    position: pos
  })
  marker.addListener('click', function() {
    closeWin();
    infoWin.open(map, this);
    infoWinArr.push(infoWin);
    addCal = document.querySelector('#add-cal');
    addCal.addEventListener('click', function() {
        $.ajax({
          url: beURL + '/events/new',
          data: event,
          method: 'POST',
          dataType: 'json'
        }).done(function(response) {
          console.log(response);
        }) 
    })
  })
}
function createMarker ( event ) { var pos = { lat : event . latitude , lng : event . longitude } ; var contentStr = '<div id="content">' + '<p><b>' + event . artists + ' @ ' + event . city + ', ' + event . region + '</b></p>' + '<p>' + event . formatted_datetime + '</p>' + '<p>' + event . name + '</p>' + '<button id="add-cal">Add to Calendar</button>' + '</div>' var marker = new google . maps . Marker ( { position : pos , animation : google . maps . Animation . DROP , map : map } ) var infoWin = new google . maps . InfoWindow ( { content : contentStr , position : pos } ) marker . addListener ( 'click' , function ( ) { closeWin ( ) ; infoWin . open ( map , this ) ; infoWinArr . push ( infoWin ) ; addCal = document . querySelector ( '#add-cal' ) ; addCal . addEventListener ( 'click' , function ( ) { $ . ajax ( { url : beURL + '/events/new' , data : event , method : 'POST' , dataType : 'json' } ) . done ( function ( response ) { console . log ( response ) ; } ) } ) } ) }
create marker, infoWindow, add button for each call
create marker infoWindow add button for each call
// console.log('infoWindow', infoWindow); // add to cal // end ajax