diff --git a/lib/tiles/offlineEnabler.js b/lib/tiles/offlineEnabler.js index afd1aca..7fd66d7 100644 --- a/lib/tiles/offlineEnabler.js +++ b/lib/tiles/offlineEnabler.js @@ -302,7 +302,8 @@ define([ handleAs: "text/plain; charset=x-user-defined", headers: { "X-Requested-With": "" //bypasses a dojo xhr bug - } + }, + timeout: 2000 }).then(function(response){ var img = Base64Utils.wordToBase64(Base64Utils.stringToWord(response)); callback(img.length + url.length); diff --git a/samples/tiles/tiles-indexed-db.html b/samples/tiles/tiles-indexed-db.html index a4f8eed..8060f61 100644 --- a/samples/tiles/tiles-indexed-db.html +++ b/samples/tiles/tiles-indexed-db.html @@ -151,7 +151,8 @@ var dojoConfig = { paths: { tiles: locationPath + "/../../lib/tiles", - vendor: locationPath + "/../../vendor" + vendor: locationPath + "/../../vendor", + utils: locationPath + "/../../utils" } } window.proxyPath = "../../lib/proxy.php"; diff --git a/samples/tiles/tiles-indexed-db.js b/samples/tiles/tiles-indexed-db.js index 9d121d6..f915b56 100644 --- a/samples/tiles/tiles-indexed-db.js +++ b/samples/tiles/tiles-indexed-db.js @@ -12,7 +12,7 @@ require(["esri/map", "dojo/dom", "dojo/on", "dojo/query", "vendor/bootstrap-map-js/src/js/bootstrapmap", "esri/urlUtils", "esri/geometry/webMercatorUtils", - "tiles/offlineEnabler", + "tiles/offlineEnabler","utils/debouncer", "dojo/dom-construct", "dojo/domReady!"], function(Map, GraphicsLayer, Graphic, SimpleFillSymbol, @@ -20,7 +20,7 @@ require(["esri/map", dom, on, query, BootstrapMap, urlUtils, webMercatorUtils, - offlineEnabler, + offlineEnabler,debouncer, domConstruct) { var scalebar; @@ -106,7 +106,9 @@ require(["esri/map", function initEvents() { - map.on('extent-change', updateTileCountEstimation ); + map.on('extent-change',debouncer.debounceMap(function(){ + updateTileCountEstimation(); + }) ); on(dojo.byId('minLevel'),'change', updateTileCountEstimation); on(dojo.byId('maxLevel'),'change', updateTileCountEstimation); @@ -117,6 +119,7 @@ require(["esri/map", function initOffline() { console.log("extending"); + offlineEnabler.extend(basemapLayer,function(success) { if(success) @@ -189,7 +192,8 @@ require(["esri/map", //NOTE: Number of tiles per zoom level will not change unless the map div changes size var levelEstimation; - try{basemapLayer.getLevelEstimation(map.extent,minLevel,function(result){ + + basemapLayer.getLevelEstimation(map.extent,minLevel,function(result){ levelEstimation = result; for(var level=minLevel; level<=maxLevel; level++) @@ -217,7 +221,7 @@ require(["esri/map", rowContent = "