Disable edit modes when zoomed out (fixes #473)

This commit is contained in:
John Firebaugh
2013-01-23 18:59:04 -05:00
parent f7a10c1ab6
commit 1eedbecee4
2 changed files with 12 additions and 8 deletions

View File

@@ -40,13 +40,13 @@ window.iD = function(container) {
.on('click.editor', function (mode) { controller.enter(mode); });
function disableTooHigh() {
if (map.zoom() < 16) {
if (map.editable()) {
notice.message('');
buttons.attr('disabled', null);
} else {
buttons.attr('disabled', 'disabled');
notice.message('Zoom in to edit the map');
controller.enter(iD.modes.Browse());
} else {
notice.message('');
buttons.attr('disabled', null);
}
}
@@ -209,9 +209,9 @@ window.iD = function(container) {
});
var keybinding = d3.keybinding('main')
.on('P', function() { controller.enter(iD.modes.AddPoint()); })
.on('L', function() { controller.enter(iD.modes.AddLine()); })
.on('A', function() { controller.enter(iD.modes.AddArea()); })
.on('P', function() { if (map.editable()) controller.enter(iD.modes.AddPoint()); })
.on('L', function() { if (map.editable()) controller.enter(iD.modes.AddLine()); })
.on('A', function() { if (map.editable()) controller.enter(iD.modes.AddArea()); })
.on('⌘+Z', function() { history.undo(); })
.on('⌃+Z', function() { history.undo(); })
.on('⌘+⇧+Z', function() { history.redo(); })

View File

@@ -161,7 +161,7 @@ iD.Map = function() {
dispatch.move(map);
surface.attr('data-zoom', ~~map.zoom());
tilegroup.call(background);
if (map.zoom() >= 16) {
if (map.editable()) {
connection.loadTiles(projection);
drawVector(difference);
} else {
@@ -331,6 +331,10 @@ iD.Map = function() {
}
};
map.editable = function() {
return map.zoom() >= 16;
};
map.minzoom = function(_) {
if (!arguments.length) return minzoom;
minzoom = _;