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

38 lines
1.3 KiB
CoffeeScript
Raw Normal View History

$(document).ready ->
2014-08-23 16:59:42 +02:00
$('.maps #map').each ->
map = L.map 'map'
2014-10-05 13:35:42 +02:00
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
2014-08-23 16:59:42 +02:00
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a>'
).addTo map
$.getJSON '/maps.json', (json) ->
layer = L.geoJson(json,
2014-08-23 16:59:42 +02:00
onEachFeature: (feature, layer) ->
# Does this feature have a property named popupContent?
if (feature.properties && feature.properties.popupContent)
layer.bindPopup feature.properties.popupContent
2014-08-23 16:59:42 +02:00
).addTo map
# Automatic focus to all displayed events
map.fitBounds layer.getBounds()
2014-08-23 16:59:42 +02:00
$('.events #map, .moderations #map').each ->
2014-08-23 16:59:42 +02:00
coord = [$(this).attr('latitude'), $(this).attr('longitude')]
2014-08-02 15:51:45 +02:00
2014-08-23 16:59:42 +02:00
map = L.map('map').setView [coord[0], coord[1]], 16
2014-10-05 13:35:42 +02:00
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
2014-08-23 16:59:42 +02:00
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a>'
).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
2014-08-23 16:59:42 +02:00
marker = L.marker([coord[0], coord[1]]).addTo map