2014-04-28 00:33:21 +02:00
|
|
|
$(document).ready ->
|
2014-10-28 00:23:11 +01:00
|
|
|
$('#map.events').each ->
|
2014-09-21 14:32:59 +02:00
|
|
|
map = L.map 'map'
|
2014-07-31 01:32:47 +02:00
|
|
|
|
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: '© <a href="http://osm.org/copyright">OpenStreetMap</a>'
|
|
|
|
).addTo map
|
|
|
|
|
2014-10-29 11:42:07 +01:00
|
|
|
url = $(this).data 'url'
|
2014-10-31 14:24:40 +01:00
|
|
|
if location.search && url.indexOf('?') >= 0
|
2014-10-29 11:42:07 +01:00
|
|
|
url += '&' + location.search.substr 1
|
|
|
|
else
|
|
|
|
url += location.search
|
|
|
|
|
|
|
|
$.getJSON url, (json) ->
|
2014-10-28 00:47:37 +01:00
|
|
|
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)
|
2014-09-20 18:41:19 +02:00
|
|
|
layer.bindPopup feature.properties.popupContent
|
2014-08-23 16:59:42 +02:00
|
|
|
|
2014-10-28 00:23:11 +01:00
|
|
|
map.addLayer L.markerClusterGroup().addLayer layer
|
|
|
|
|
2014-10-28 00:47:37 +01:00
|
|
|
if (layer.getBounds()._northEast && layer.getBounds()._southWest)
|
|
|
|
# Automatic focus to all displayed events
|
|
|
|
map.fitBounds layer.getBounds()
|
|
|
|
else
|
|
|
|
$('#map.events').remove()
|
2014-08-23 16:59:42 +02:00
|
|
|
|
2014-10-28 00:23:11 +01:00
|
|
|
$('#map.event').each ->
|
|
|
|
coord = [$(this).data('latitude'), $(this).data('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: '© <a href="http://osm.org/copyright">OpenStreetMap</a>'
|
2014-07-31 01:32:47 +02:00
|
|
|
).addTo map
|
|
|
|
|
2014-10-29 11:42:07 +01:00
|
|
|
url = $(this).data 'url'
|
2014-12-13 12:32:05 +01:00
|
|
|
if location.search && url.indexOf('?') >= 0
|
2014-10-29 11:42:07 +01:00
|
|
|
url += '&' + location.search.substr 1
|
|
|
|
else
|
|
|
|
url += location.search
|
|
|
|
|
|
|
|
$.getJSON url, (json) ->
|
2014-10-28 00:47:37 +01:00
|
|
|
layer = L.geoJson json,
|
2014-07-31 01:32:47 +02:00
|
|
|
onEachFeature: (feature, layer) ->
|
|
|
|
# Does this feature have a property named popupContent?
|
|
|
|
if (feature.properties && feature.properties.popupContent)
|
2014-09-21 14:32:59 +02:00
|
|
|
layer.bindPopup(feature.properties.popupContent)
|
2014-08-23 16:59:42 +02:00
|
|
|
|
2014-10-26 17:48:20 +01:00
|
|
|
map.addLayer L.markerClusterGroup().addLayer layer
|
2014-10-26 16:51:16 +01:00
|
|
|
|
2014-08-23 16:59:42 +02:00
|
|
|
marker = L.marker([coord[0], coord[1]]).addTo map
|