$(document).ready -> if $('#map').size() > 0 map = L.map('map').setView [46.5, 4], 6 L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', #L.tileLayer('http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png', #L.tileLayer('http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpeg', #attribution: 'Tiles Courtesy of MapQuest — Map data © OpenStreetMap contributors, CC-BY-SA', attribution: '© OpenStreetMap contributors', #subdomains: '1234' ).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