diff --git a/app/assets/javascripts/maps.js.coffee b/app/assets/javascripts/maps.js.coffee index 0fab8654..c5899323 100644 --- a/app/assets/javascripts/maps.js.coffee +++ b/app/assets/javascripts/maps.js.coffee @@ -7,17 +7,19 @@ $(document).ready -> ).addTo map $.getJSON $(this).data('url') + location.search, (json) -> - layer = L.geoJson(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 - ) map.addLayer L.markerClusterGroup().addLayer layer - # Automatic focus to all displayed events - map.fitBounds layer.getBounds() + if (layer.getBounds()._northEast && layer.getBounds()._southWest) + # Automatic focus to all displayed events + map.fitBounds layer.getBounds() + else + $('#map.events').remove() $('#map.event').each -> coord = [$(this).data('latitude'), $(this).data('longitude')] @@ -29,12 +31,11 @@ $(document).ready -> ).addTo map $.getJSON $(this).data('url') + location.search, (json) -> - layer = L.geoJson(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) - ) map.addLayer L.markerClusterGroup().addLayer layer