" + feature.opts.name + "
" + feature.opts.city + " | " + feature.opts.type + "
"
marker.bindPopup(popupContent);
return marker
}
}).addTo(map);
// Set initial map extent to the bounds of the marker layer
// This way we'll all of our markers when we open the map!
map.fitBounds(markerLayer.getBounds())
// Use jQuery w/ Sheetsee so that when you click on a place in the table, the map zooms to the location and the infopane updates
$('.beerRow').on("click", function(event) {
// Clear the styling in the table for the previously selected row
$('.beerRow').removeClass("selectedRow")
// Select the row of the location clicked in the table
var rowNumber = $(this).closest("tr").attr("id")
// Add styling to the selected row
$('#' + rowNumber).addClass("selectedRow")
// Sets a variable that is only the data for the selected row
var dataElement = Sheetsee.getMatches(gData, rowNumber, "rowNumber")
// Fits the selected row attributes to the infopane template (selectedBeer)
var selectedBeer = Sheetsee.ich.selectedBeer({
rows: dataElement
})
console.log(selectedBeer)
// Adds the filled template as HTML to infopane
$('#selectedBeer').html(selectedBeer).css("display", "inline")
// Gets the coordinates of the selected row
var selectedCoords = [dataElement[0].lat, dataElement[0].long]
// Set the map view to the selected row's coordinates (w/ fixed zoom level))
map.setView(selectedCoords, 17)
})
// Add click listener to the markerLayer
markerLayer.on('click', function(e) {
// clear any selected rows
$('.beerRow').removeClass("selectedRow")
// get row number of selected marker
var rowNumber = e.layer.feature.opts.rowNumber
// find that row in the table and make consider it selected
$('#' + rowNumber).addClass("selectedRow")
// using row number, get the data for the selected spot
var dataElement = Sheetsee.getMatches(gData, rowNumber.toString(), "rowNumber")
// take those details and re-write the selected spot section
var selectedBeer = Sheetsee.ich.selectedBeer({
rows: dataElement
})
// center the map on the selected element
selectedMarkerLocation = [dataElement[0].lat, dataElement[0].long]
//map.panTo([dataElement[0].lat, dataElement[0].long])
map.setView(selectedMarkerLocation, 17)
// update the spot listing
$('#selectedBeer').html(selectedBeer).css("display", "inline")
})
// resets the map to the extent of the feature layer when you click the reset map button
$('.resetMap').click(function() {
// Clear whatever row is selected of the .selectedRow style
$('.beerRow').removeClass("selectedRow")
// Clear the infopane of the info about the most recently selected beer place
$('#selectedBeer').css("display", "none")
// Center map and set zoom to include all the markers
map.fitBounds(markerLayer.getBounds())
})
}