agenda-libre-ruby/app/assets/javascripts/maps.js.coffee

21 lines
795 B
CoffeeScript
Raw Normal View History

$(document).ready ->
if $('#map').size() > 0
map = L.map('map')
L.tileLayer('https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png',
id: 'examples.map-i86knfo3',
attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
'Imagery © <a href="http://mapbox.com">Mapbox</a>'
).addTo map
$.getJSON '/maps.json', (json) ->
map.setView [45, 6], 6
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