Skip to content

Commit

Permalink
Avoid requesting blank tiles from EsriWorldImagery
Browse files Browse the repository at this point in the history
(closes #4327)

This allows the real tiles to overzoom, so the user does not see
tiles with the "map data not yet available" message
  • Loading branch information
bhousel committed Sep 9, 2017
1 parent c6189bb commit 1c9719d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
2 changes: 2 additions & 0 deletions modules/renderer/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ export function rendererBackground(context) {
backgroundSources = dataImagery.map(function(source) {
if (source.type === 'bing') {
return rendererBackgroundSource.Bing(source, dispatch);
} else if (source.id === 'EsriWorldImagery') {
return rendererBackgroundSource.Esri(source);
} else {
return rendererBackgroundSource(source);
}
Expand Down
50 changes: 50 additions & 0 deletions modules/renderer/background_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,56 @@ rendererBackgroundSource.Bing = function(data, dispatch) {
};



rendererBackgroundSource.Esri = function(data) {

// don't request blank tiles, instead overzoom real tiles - #4327
if (data.template.match(/blankTile/) === null) {
data.template = data.template + '?blankTile=false';
}

var esri = rendererBackgroundSource(data),
cache = {};

esri.getVintage = function(center, tileCoord, callback) {
var tileId = tileCoord.slice(0, 3).join('/');
// FIXME: construct service URL
// zoom = Math.min(tileCoord[2], esri.scaleExtent[1]),
// centerPoint = center[1] + ',' + center[0], // lat,lng
// url = 'https://dev.virtualearth.net/REST/v1/Imagery/Metadata/Aerial/' + centerPoint +
// '?zl=' + zoom + '&key=' + key + '&jsonp={callback}';

if (!cache[tileId]) {
cache[tileId] = {};
}
if (cache[tileId] && cache[tileId].vintage) {
return callback(null, cache[tileId].vintage);
}

// FIXME: remove dummy result:
callback(null, { start: null, end: null, range: '? - ?'});

// FIXME: call service instead:
// jsonpRequest(url, function(result) {
// var err = (!result && 'Unknown Error') || result.errorDetails;
// if (err) {
// return callback(err);
// } else {
// var vintage = {
// start: localeDateString(result.resourceSets[0].resources[0].vintageStart),
// end: localeDateString(result.resourceSets[0].resources[0].vintageEnd)
// };
// vintage.range = vintageRange(vintage);
// cache[tileId].vintage = vintage;
// return callback(null, vintage);
// }
// });
};

return esri;
};


rendererBackgroundSource.None = function() {
var source = rendererBackgroundSource({ id: 'none', template: '' });

Expand Down

0 comments on commit 1c9719d

Please sign in to comment.