Limit number of pages to fetch from Mapillary search API

(closes #3149)
This commit is contained in:
Bryan Housel
2016-06-06 20:45:14 -04:00
parent 02ba1ae0fd
commit f2cde0bfef
+4 -2
View File
@@ -6,6 +6,7 @@ iD.services.mapillary = function() {
viewerjs = 'https://npmcdn.com/mapillary-js@1.3.0/dist/mapillary-js.min.js',
clientId = 'NzNRM2otQkR2SHJzaXJmNmdQWVQ0dzo1ZWYyMmYwNjdmNDdlNmVi',
maxResults = 1000,
maxPages = 10,
tileZoom = 14;
@@ -185,6 +186,7 @@ iD.services.mapillary = function() {
if (err || !data.features || !data.features.length) return;
var features = [],
nextPage = page + 1,
feature, loc, d;
for (var i = 0; i < data.features.length; i++) {
@@ -202,8 +204,8 @@ iD.services.mapillary = function() {
if (which === 'images') dispatch.loadedImages();
if (which === 'signs') dispatch.loadedSigns();
if (data.features.length === maxResults) {
loadTilePage(which, url, tile, ++page);
if (data.features.length === maxResults && nextPage < maxPages) {
loadTilePage(which, url, tile, nextPage);
}
}
);