mirror of
https://github.com/Esri/offline-editor-js.git
synced 2025-12-15 15:20:05 +00:00
added a bunch of code comments to clarify functionality
This commit is contained in:
parent
9b905ee118
commit
f29fe2c547
@ -127,6 +127,11 @@ require(["esri/map","utils/appCacheManager","tiles/offlineTilesEnabler","dojo/on
|
|||||||
Offline.check();
|
Offline.check();
|
||||||
Offline.on('up down', updateState );
|
Offline.on('up down', updateState );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* There have been a few bugs in the offline detection library (offline.min.js)
|
||||||
|
* This is a utility check to 100% validate if the application is online or
|
||||||
|
* offline prior to launching any map functionality.
|
||||||
|
*/
|
||||||
verifyOnline(function(result){ console.log("VERIFY ONLINE " + result)
|
verifyOnline(function(result){ console.log("VERIFY ONLINE " + result)
|
||||||
result == true ? _isOnline = true : _isOnline = false;
|
result == true ? _isOnline = true : _isOnline = false;
|
||||||
startMap();
|
startMap();
|
||||||
@ -155,7 +160,8 @@ require(["esri/map","utils/appCacheManager","tiles/offlineTilesEnabler","dojo/on
|
|||||||
map.on("extent-change",function(evt){
|
map.on("extent-change",function(evt){
|
||||||
updateOfflineUsage();
|
updateOfflineUsage();
|
||||||
console.log("Zoom level = " + map.getLevel())
|
console.log("Zoom level = " + map.getLevel())
|
||||||
})
|
});
|
||||||
|
|
||||||
appCacheManager = new AppCacheManager(true,true);
|
appCacheManager = new AppCacheManager(true,true);
|
||||||
appCacheManager.on(appCacheManager.CACHE_EVENT,cacheEventHandler);
|
appCacheManager.on(appCacheManager.CACHE_EVENT,cacheEventHandler);
|
||||||
appCacheManager.on(appCacheManager.CACHE_ERROR,cacheErrorHandler);
|
appCacheManager.on(appCacheManager.CACHE_ERROR,cacheErrorHandler);
|
||||||
@ -239,6 +245,9 @@ require(["esri/map","utils/appCacheManager","tiles/offlineTilesEnabler","dojo/on
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility function to validate min and max zoom settings of the map
|
||||||
|
*/
|
||||||
function getMinMaxZoom(){
|
function getMinMaxZoom(){
|
||||||
|
|
||||||
var zoom = {};
|
var zoom = {};
|
||||||
@ -250,6 +259,9 @@ require(["esri/map","utils/appCacheManager","tiles/offlineTilesEnabler","dojo/on
|
|||||||
return zoom;
|
return zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reports the process while downloading tiles.
|
||||||
|
*/
|
||||||
function reportProgress(progress)
|
function reportProgress(progress)
|
||||||
{
|
{
|
||||||
console.log("downloading tiles...");
|
console.log("downloading tiles...");
|
||||||
@ -279,6 +291,10 @@ require(["esri/map","utils/appCacheManager","tiles/offlineTilesEnabler","dojo/on
|
|||||||
return _wantToCancel; //determines if a cancel request has been issued
|
return _wantToCancel; //determines if a cancel request has been issued
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces offlineTileEnabler to go online or offline.
|
||||||
|
* If it is offline it will try to find a tile in the local database.
|
||||||
|
*/
|
||||||
function goOnlineOffline(){
|
function goOnlineOffline(){
|
||||||
if(imgOfflineIndicator.offlineColor == "blue"){
|
if(imgOfflineIndicator.offlineColor == "blue"){
|
||||||
btnOnlineOffline.innerHTML = "2. Go Online";
|
btnOnlineOffline.innerHTML = "2. Go Online";
|
||||||
@ -294,6 +310,10 @@ require(["esri/map","utils/appCacheManager","tiles/offlineTilesEnabler","dojo/on
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manually starts the process to download and store tiles
|
||||||
|
* in the local database
|
||||||
|
*/
|
||||||
function downloadTiles(){
|
function downloadTiles(){
|
||||||
baseMapLayer.deleteAllTiles(function(success,err){
|
baseMapLayer.deleteAllTiles(function(success,err){
|
||||||
if(success == false){
|
if(success == false){
|
||||||
@ -322,6 +342,11 @@ require(["esri/map","utils/appCacheManager","tiles/offlineTilesEnabler","dojo/on
|
|||||||
}.bind(this))
|
}.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts an http request to verify if app is online or offline.
|
||||||
|
* Use this in conjunction with the offline checker library: offline.min.js
|
||||||
|
* @param callback
|
||||||
|
*/
|
||||||
function verifyOnline(callback){
|
function verifyOnline(callback){
|
||||||
var req = new XMLHttpRequest();
|
var req = new XMLHttpRequest();
|
||||||
req.open("GET", "images/blue-pin.png?" + (Math.floor(Math.random() * 1000000000)), true);
|
req.open("GET", "images/blue-pin.png?" + (Math.floor(Math.random() * 1000000000)), true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user