diff --git a/modules/services/mapillary.js b/modules/services/mapillary.js index 866a9778e..ddf72eabc 100644 --- a/modules/services/mapillary.js +++ b/modules/services/mapillary.js @@ -17,7 +17,7 @@ import { import rbush from 'rbush'; -import { geoExtent } from '../geo'; +import { geoExtent, geoScaleToZoom } from '../geo'; import { svgDefs } from '../svg'; import { utilQsString, utilRebind, utilTiler } from '../util'; @@ -53,8 +53,7 @@ function maxPageAtZoom(z) { function loadTiles(which, url, projection) { - var s = projection.scale() * 2 * Math.PI; - var currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0)); + var currZoom = Math.floor(geoScaleToZoom(projection.scale())); var tiles = tiler.getTiles(projection, tileZoom); // abort inflight requests that are no longer needed diff --git a/modules/services/openstreetcam.js b/modules/services/openstreetcam.js index 8fa1574e7..4c0c4cd28 100644 --- a/modules/services/openstreetcam.js +++ b/modules/services/openstreetcam.js @@ -21,15 +21,14 @@ import { import rbush from 'rbush'; -import { geoExtent } from '../geo'; - -import { utilTiler } from '../util'; +import { geoExtent, geoScaleToZoom } from '../geo'; import { utilDetect } from '../util/detect'; import { utilQsString, utilRebind, - utilSetTransform + utilSetTransform, + utilTiler } from '../util'; @@ -63,8 +62,7 @@ function maxPageAtZoom(z) { function loadTiles(which, url, projection) { - var s = projection.scale() * 2 * Math.PI; - var currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0)); + var currZoom = Math.floor(geoScaleToZoom(projection.scale())); var tiles = tiler.getTiles(projection, tileZoom); // abort inflight requests that are no longer needed diff --git a/modules/services/streetside.js b/modules/services/streetside.js index ea9971f2d..39d5f7990 100644 --- a/modules/services/streetside.js +++ b/modules/services/streetside.js @@ -81,8 +81,6 @@ function localeTimestamp(s) { * loadTiles() wraps the process of generating tiles and then fetching image points for each tile. */ function loadTiles(which, url, projection, margin) { - var s = projection.scale() * 2 * Math.PI; - var currZoom = Math.floor(Math.max(Math.log(s) / Math.log(2) - 8, 0)); var tiles = tiler.margin(margin).getTiles(projection, tileZoom); // abort inflight requests that are no longer needed @@ -97,14 +95,14 @@ function loadTiles(which, url, projection, margin) { }); tiles.forEach(function (tile) { - loadNextTilePage(which, currZoom, url, tile); + loadNextTilePage(which, url, tile); }); } /** * loadNextTilePage() load data for the next tile page in line. */ -function loadNextTilePage(which, currZoom, url, tile) { +function loadNextTilePage(which, url, tile) { var cache = _ssCache[which]; var nextPage = cache.nextPage[tile.id] || 0; var id = tile.id + ',' + String(nextPage); @@ -118,7 +116,7 @@ function loadNextTilePage(which, currZoom, url, tile) { // [].shift() removes the first element, some statistics info, not a bubble point bubbles.shift(); - var features = bubbles.map(function (bubble) { + var features = bubbles.map(function(bubble) { if (cache.points[bubble.id]) return null; // skip duplicates var loc = [bubble.lo, bubble.la];