From e19e996f1f8526567a2b6ec0c161628a24aee9ad Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 1 Oct 2013 22:46:16 +0100 Subject: [PATCH] Improve behaviour of browse pages when no bounding box is available --- app/assets/javascripts/browse.js | 7 +++---- app/assets/javascripts/leaflet.extend.js.erb | 6 ++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/browse.js b/app/assets/javascripts/browse.js index 11818a171..565af41af 100644 --- a/app/assets/javascripts/browse.js +++ b/app/assets/javascripts/browse.js @@ -61,9 +61,10 @@ $(document).ready(function () { zoom: true, callback: function(extent) { $("#loading").hide(); - $("#browse_map .secondary-actions").show(); - if (extent) { + if (extent && extent.isValid()) { + $("#browse_map .secondary-actions").show(); + $("a.bbox[data-editor=remote]").click(function () { return remoteEditHandler(extent); }); @@ -76,8 +77,6 @@ $(document).ready(function () { $("#object_edit").show(); updatelinks(map.getCenter(), 16, null, extent, object); - } else { - $("#small_map").hide(); } } }); diff --git a/app/assets/javascripts/leaflet.extend.js.erb b/app/assets/javascripts/leaflet.extend.js.erb index 966d0276b..0ab0fface 100644 --- a/app/assets/javascripts/leaflet.extend.js.erb +++ b/app/assets/javascripts/leaflet.extend.js.erb @@ -140,8 +140,10 @@ L.extend(L.Map.prototype, { map._objectLayer.addData(xml); - if (options.zoom) map.fitBounds(map._objectLayer.getBounds()); - if (options.callback) options.callback(map._objectLayer.getBounds()); + var bounds = map._objectLayer.getBounds(); + + if (options.zoom && bounds.isValid()) map.fitBounds(bounds); + if (options.callback) options.callback(bounds); map._objectLayer.addTo(map); } -- 2.39.5