$(document).ready -> $('.maps #map').each -> map = L.map 'map' L.tileLayer('http://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png', attribution: '© OpenStreetMap' ).addTo map $.getJSON '/maps.json', (json) -> layer = L.geoJson(json, onEachFeature: (feature, layer) -> # Does this feature have a property named popupContent? if (feature.properties && feature.properties.popupContent) layer.bindPopup feature.properties.popupContent ).addTo map # Automatic focus to all displayed events map.fitBounds layer.getBounds() $('.events #map, .moderations #map').each -> coord = [$(this).attr('latitude'), $(this).attr('longitude')] map = L.map('map').setView [coord[0], coord[1]], 16 L.tileLayer('http://{s}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png', attribution: '© OpenStreetMap' ).addTo map $.getJSON '/maps.json', (json) -> L.geoJson(json, onEachFeature: (feature, layer) -> # Does this feature have a property named popupContent? if (feature.properties && feature.properties.popupContent) layer.bindPopup(feature.properties.popupContent) ).addTo map marker = L.marker([coord[0], coord[1]]).addTo map