From 8f39cbe0d267c8b54107fa1ff420db18ff01e7f8 Mon Sep 17 00:00:00 2001
From: echarp <emmanuel.charpentier@free.fr>
Date: Tue, 28 Oct 2014 00:47:37 +0100
Subject: [PATCH] =?UTF-8?q?Une=20carte=20sans=20=C3=A9v=C3=A9nement=20est?=
 =?UTF-8?q?=20maintenant=20supprim=C3=A9e?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/assets/javascripts/maps.js.coffee | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/app/assets/javascripts/maps.js.coffee b/app/assets/javascripts/maps.js.coffee
index 0fab86540..c5899323e 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
 
-- 
GitLab