From 5fbf5a8667e8419dc3a78f0e71ecc523fd4cb179 Mon Sep 17 00:00:00 2001 From: Young Hahn Date: Fri, 29 Apr 2016 10:46:08 -0400 Subject: [PATCH] Allow an explicit minzoom/maxzoom to be set in config to limit zoom rage --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index b602fe1..353d253 100644 --- a/index.js +++ b/index.js @@ -276,5 +276,8 @@ function zoomBySpeed (config, step) { var zoomDiff = speedDiff / 70; // Determine new zoom level var response = config.zoom - zoomDiff; - return response; + + var minzoom = config.minzoom || (config.zoom-1); + var maxzoom = config.maxzoom || (config.zoom+1); + return Math.min(maxzoom, Math.max(minzoom, response)); }