mirror of
https://github.com/Esri/offline-editor-js.git
synced 2025-12-15 15:20:05 +00:00
better, restored max zoom level. Tile counts still aren't correct for the lower number zoom levels.
This commit is contained in:
parent
2ace73e5c1
commit
0295fc40c0
@ -30,6 +30,7 @@ define([
|
|||||||
console.log("extending layer", layer.url);
|
console.log("extending layer", layer.url);
|
||||||
|
|
||||||
layer._tileUrlArr = [];
|
layer._tileUrlArr = [];
|
||||||
|
layer._tileSize = 0;
|
||||||
|
|
||||||
//Reset _tileUrlArr when extent is changed
|
//Reset _tileUrlArr when extent is changed
|
||||||
layer._map.on("update-start",function(evt){
|
layer._map.on("update-start",function(evt){
|
||||||
@ -100,21 +101,19 @@ define([
|
|||||||
return tileid;
|
return tileid;
|
||||||
};
|
};
|
||||||
|
|
||||||
layer.getLevelEstimation = function(extent, level,callback)
|
layer.getLevelEstimation = function(extent, level, tileSize)
|
||||||
{
|
{
|
||||||
//var tilingScheme = new TilingScheme(this,geometry);
|
var tilingScheme = new TilingScheme(this,geometry);
|
||||||
//var cellIds = tilingScheme.getAllCellIdsInExtent(extent,level);
|
var cellIds = tilingScheme.getAllCellIdsInExtent(extent,level);
|
||||||
var cellIdLength = this._tileUrlArr.length;
|
|
||||||
this.estimateTileSize(function(tileSize){
|
|
||||||
var levelEstimation = {
|
|
||||||
level: level,
|
|
||||||
tileCount: cellIdLength,
|
|
||||||
sizeBytes: cellIdLength * tileSize
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(levelEstimation);
|
var levelEstimation = {
|
||||||
});
|
level: level,
|
||||||
};
|
tileCount: cellIds.length,
|
||||||
|
sizeBytes: cellIds.length * tileSize
|
||||||
|
}
|
||||||
|
|
||||||
|
return levelEstimation;
|
||||||
|
};
|
||||||
|
|
||||||
layer.prepareForOffline = function(minLevel, maxLevel, extent, reportProgress)
|
layer.prepareForOffline = function(minLevel, maxLevel, extent, reportProgress)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -182,30 +182,32 @@ require(["esri/map",
|
|||||||
{
|
{
|
||||||
console.log('updating');
|
console.log('updating');
|
||||||
var zoomLevel = map.getLevel();
|
var zoomLevel = map.getLevel();
|
||||||
dojo.byId('currentLevel').value = zoomLevel;
|
dojo.byId('currentLevel').value = zoomLevel;
|
||||||
dojo.byId('maxLevel').value = zoomLevel;
|
|
||||||
|
|
||||||
var minLevel = parseInt(dojo.byId('minLevel').value);
|
var minLevel = parseInt(dojo.byId('minLevel').value);
|
||||||
var maxLevel = zoomLevel;
|
var maxLevel = parseInt(dojo.byId('maxLevel').value);
|
||||||
|
|
||||||
|
if( maxLevel > zoomLevel + 3 || maxLevel > basemapLayer.maxLevel)
|
||||||
|
{
|
||||||
|
maxLevel = Math.min(basemapLayer.maxLevel, zoomLevel + 3);
|
||||||
|
dojo.byId('maxLevel').value = maxLevel;
|
||||||
|
}
|
||||||
|
|
||||||
var totalEstimation = { tileCount:0, sizeBytes:0 }
|
var totalEstimation = { tileCount:0, sizeBytes:0 }
|
||||||
|
|
||||||
domConstruct.empty('tile-count-table-body');
|
domConstruct.empty('tile-count-table-body');
|
||||||
|
|
||||||
//NOTE: Number of tiles per zoom level will not change unless the map div changes size
|
basemapLayer.estimateTileSize(function(tileSize){
|
||||||
var levelEstimation;
|
|
||||||
|
|
||||||
basemapLayer.getLevelEstimation(map.extent,minLevel,function(result){
|
|
||||||
levelEstimation = result;
|
|
||||||
|
|
||||||
for(var level=minLevel; level<=maxLevel; level++)
|
for(var level=minLevel; level<=maxLevel; level++)
|
||||||
{
|
{
|
||||||
|
var levelEstimation = basemapLayer.getLevelEstimation(map.extent,level,tileSize);
|
||||||
|
|
||||||
totalEstimation.tileCount += levelEstimation.tileCount;
|
totalEstimation.tileCount += levelEstimation.tileCount;
|
||||||
totalEstimation.sizeBytes += levelEstimation.sizeBytes;
|
totalEstimation.sizeBytes += levelEstimation.sizeBytes;
|
||||||
|
|
||||||
if( levelEstimation.tileCount > 1 && levelEstimation.tileCount < 5000)
|
if( levelEstimation.tileCount > 1)
|
||||||
{
|
{
|
||||||
var rowContent = [level, levelEstimation.tileCount, Math.round(levelEstimation.sizeBytes / 1024 / 1024 * 100) / 100 + " Mb"]
|
var rowContent = [levelEstimation.level, levelEstimation.tileCount, Math.round(levelEstimation.sizeBytes / 1024 / 1024 * 100) / 100 + " Mb"]
|
||||||
rowContent = "<td>" + rowContent.join("</td><td>") + "</td>";
|
rowContent = "<td>" + rowContent.join("</td><td>") + "</td>";
|
||||||
var tr = domConstruct.place("<tr>", dojo.byId('tile-count-table-body'),'last')
|
var tr = domConstruct.place("<tr>", dojo.byId('tile-count-table-body'),'last')
|
||||||
domConstruct.place(rowContent, tr,'last');
|
domConstruct.place(rowContent, tr,'last');
|
||||||
@ -223,8 +225,35 @@ require(["esri/map",
|
|||||||
rowContent = "<td><b>" + rowContent.join("</b></td><td><b>") + "</b></td>";
|
rowContent = "<td><b>" + rowContent.join("</b></td><td><b>") + "</b></td>";
|
||||||
tr = domConstruct.place("<tr>", dojo.byId('tile-count-table-body'),'last')
|
tr = domConstruct.place("<tr>", dojo.byId('tile-count-table-body'),'last')
|
||||||
domConstruct.place(rowContent, tr,'last');
|
domConstruct.place(rowContent, tr,'last');
|
||||||
});
|
})
|
||||||
|
|
||||||
|
// for(var level=minLevel; level<=maxLevel; level++)
|
||||||
|
// {
|
||||||
|
// totalEstimation.tileCount += levelEstimation.tileCount;
|
||||||
|
// totalEstimation.sizeBytes += levelEstimation.sizeBytes;
|
||||||
|
//
|
||||||
|
// if( levelEstimation.tileCount > 1 && levelEstimation.tileCount < 5000)
|
||||||
|
// {
|
||||||
|
// var rowContent = [level, levelEstimation.tileCount, Math.round(levelEstimation.sizeBytes / 1024 / 1024 * 100) / 100 + " Mb"]
|
||||||
|
// rowContent = "<td>" + rowContent.join("</td><td>") + "</td>";
|
||||||
|
// var tr = domConstruct.place("<tr>", dojo.byId('tile-count-table-body'),'last')
|
||||||
|
// domConstruct.place(rowContent, tr,'last');
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if( totalEstimation.tileCount > 5000 )
|
||||||
|
// {
|
||||||
|
// var tr = domConstruct.place("<tr>", dojo.byId('tile-count-table-body'),'last')
|
||||||
|
// domConstruct.place("<td colspan=4>...</td>", tr,'last');
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// rowContent = ["Total", totalEstimation.tileCount, Math.floor(totalEstimation.sizeBytes / 1024 / 1024 * 100)/100 + " Mb"];
|
||||||
|
// rowContent = "<td><b>" + rowContent.join("</b></td><td><b>") + "</b></td>";
|
||||||
|
// tr = domConstruct.place("<tr>", dojo.byId('tile-count-table-body'),'last')
|
||||||
|
// domConstruct.place(rowContent, tr,'last');
|
||||||
|
// });
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
function goOffline()
|
function goOffline()
|
||||||
@ -282,7 +311,7 @@ require(["esri/map",
|
|||||||
|
|
||||||
/* launch offline preparation process */
|
/* launch offline preparation process */
|
||||||
var minLevel = parseInt(dojo.byId('minLevel').value);
|
var minLevel = parseInt(dojo.byId('minLevel').value);
|
||||||
var maxLevel = map.getLevel();
|
var maxLevel = map.getLevel(); //current zoom level sets max extent
|
||||||
basemapLayer.prepareForOffline(minLevel, maxLevel, map.extent, reportProgress);
|
basemapLayer.prepareForOffline(minLevel, maxLevel, map.extent, reportProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user