Add minzoom check to map.zoom() (closes #2499)

This commit is contained in:
Bryan Housel
2015-01-13 22:52:53 -05:00
parent 0b93f9cdb5
commit ef2d6e75cf
2 changed files with 13 additions and 0 deletions

View File

@@ -326,6 +326,13 @@ iD.Map = function(context) {
return Math.max(Math.log(projection.scale() * 2 * Math.PI) / Math.LN2 - 8, 0);
}
if (z < minzoom) {
iD.ui.flash(context.container())
.select('.content')
.text(t('cannot_zoom'));
z = context.minEditableZoom();
}
if (setZoom(z)) {
dispatch.move(map);
}

View File

@@ -30,6 +30,12 @@ describe('iD.Map', function() {
map.zoom(4);
expect(spy).not.to.have.been.called;
});
it('respects minzoom', function() {
map.minzoom(16);
map.zoom(15);
expect(map.zoom()).to.equal(16);
});
});
describe('#zoomIn', function() {