diff --git a/js/id/modes/select.js b/js/id/modes/select.js index ac6ad4943..d071d1484 100644 --- a/js/id/modes/select.js +++ b/js/id/modes/select.js @@ -180,7 +180,7 @@ iD.modes.Select = function(context, selection, initial) { if (showMenu) context.surface().call(radialMenu); context.surface() - .on('dblclick.select', dblclick) + .on('dblclick.select', dblclick); }, 200); }; diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index 231a2e082..26ec19ebe 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -308,21 +308,25 @@ iD.Map = function(context) { return new iD.geo.Extent(projection.invert([0, dimensions[1]]), projection.invert([dimensions[0], 0])); } else { - var extent = iD.geo.Extent(_), - tl = projection([extent[0][0], extent[1][1]]), - br = projection([extent[1][0], extent[0][1]]); - - // Calculate maximum zoom that fits extent - var hFactor = (br[0] - tl[0]) / dimensions[0], - vFactor = (br[1] - tl[1]) / dimensions[1], - hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2, - vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2, - newZoom = map.zoom() - Math.max(hZoomDiff, vZoomDiff); - - map.centerZoom(extent.center(), newZoom); + map.centerZoom(extent.center(), map.extentZoom(extent)); } }; + map.extentZoom = function(_) { + var extent = iD.geo.Extent(_), + tl = projection([extent[0][0], extent[1][1]]), + br = projection([extent[1][0], extent[0][1]]); + + // Calculate maximum zoom that fits extent + var hFactor = (br[0] - tl[0]) / dimensions[0], + vFactor = (br[1] - tl[1]) / dimensions[1], + hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2, + vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2, + newZoom = map.zoom() - Math.max(hZoomDiff, vZoomDiff); + + return newZoom; + }; + map.flush = function() { context.connection().flush(); context.history().reset(); diff --git a/js/id/ui/save.js b/js/id/ui/save.js index 8b0ef57ce..5e05183b2 100644 --- a/js/id/ui/save.js +++ b/js/id/ui/save.js @@ -11,7 +11,7 @@ iD.ui.Save = function(context) { if (!history.hasChanges()) return; connection.authenticate(function(err) { - var modal = iD.ui.modal(context.container()); + modal = iD.ui.modal(context.container()); var changes = history.changes(); changes.connection = connection; modal.select('.content') @@ -67,8 +67,8 @@ iD.ui.Save = function(context) { } function clickFix(d) { - map.extent(d.entity.extent(context.graph())); - if (map.zoom() > 19) map.zoom(19); + var extent = d.entity.extent(context.graph()); + map.centerZoom(extent.center(), Math.min(19, map.extentZoom(extent))); context.enter(iD.modes.Select(context, [d.entity.id])); modal.remove(); }