From d0351662f29cbf572cc61bf56070d20c79556393 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Wed, 30 Dec 2015 18:03:27 +0000 Subject: [PATCH] don't run getBounds if it doesn't exist --- compass/public/assets/map.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/compass/public/assets/map.js b/compass/public/assets/map.js index a330141..ea210f3 100644 --- a/compass/public/assets/map.js +++ b/compass/public/assets/map.js @@ -72,20 +72,23 @@ jQuery(function($){ }).addTo(map)); // If the new layer is completely outside the current view, zoom the map to fit all layers - var layer = visible_layers[visible_layers.length - 1]; + var vlayer = visible_layers[visible_layers.length - 1]; var is_outside = false; - if(!map.getBounds().intersects(layer.getBounds())) { + if(!map.getBounds().intersects(vlayer.getBounds())) { is_outside = true; } if(is_outside) { + console.log('is outside'); + console.log(vlayer); var full_bounds; for(var i in visible_layers) { - layer = visible_layers[i]; - if(full_bounds) { - full_bounds.extend(layer.getBounds()); - } else { - full_bounds = layer.getBounds(); + if(visible_layers[i].getBounds) { + if(full_bounds) { + full_bounds.extend(visible_layers[i].getBounds()); + } else { + full_bounds = visible_layers[i].getBounds(); + } } } map.fitBounds(full_bounds);