diff --git a/js/id/modes/draw_line.js b/js/id/modes/draw_line.js index f04d2684c..a3db032b1 100644 --- a/js/id/modes/draw_line.js +++ b/js/id/modes/draw_line.js @@ -23,6 +23,8 @@ iD.modes.DrawLine = function(wayId, direction) { 'Click on other lines to connect to them, and double-click to ' + 'end the line.'); + map.minzoom(16); + history.perform( iD.actions.AddNode(node), iD.actions.AddWayNode(wayId, node.id, index)); @@ -147,6 +149,7 @@ iD.modes.DrawLine = function(wayId, direction) { mode.map.hint(false); mode.map.fastEnable(true); + mode.map.minzoom(0); surface .on('mousemove.drawline', null) diff --git a/js/id/renderer/map.js b/js/id/renderer/map.js index ac61ce5ae..29cf31669 100644 --- a/js/id/renderer/map.js +++ b/js/id/renderer/map.js @@ -12,6 +12,7 @@ iD.Map = function() { .on('zoom', zoomPan), dblclickEnabled = true, fastEnabled = true, + minzoom = 0, background = iD.Background() .projection(projection), transformProp = iD.util.prefixCSSProperty('Transform'), @@ -114,6 +115,12 @@ iD.Map = function() { return d3.event.sourceEvent.preventDefault(); } } + if (Math.log(d3.event.scale / Math.LN2 - 8) < minzoom + 1) { + iD.flash() + .select('.content') + .text('Cannot zoom out further in current mode.') + return map.zoom(16); + } var fast = (d3.event.scale === projection.scale() && fastEnabled); projection .translate(d3.event.translate) @@ -144,7 +151,7 @@ iD.Map = function() { dispatch.move(map); surface.attr('data-zoom', ~~map.zoom()); tilegroup.call(background); - if (map.zoom() > 16) { + if (map.zoom() >= 16) { connection.loadTiles(projection); drawVector(difference); } else { @@ -276,6 +283,11 @@ iD.Map = function() { } }; + map.minzoom = function(_) { + if (!arguments.length) return minzoom; + minzoom = _; + }; + map.history = function (_) { if (!arguments.length) return history; history = _;