diff --git a/lib/tiles/offlineEnabler.js b/lib/tiles/offlineEnabler.js index 83f7ba4..6d99f99 100644 --- a/lib/tiles/offlineEnabler.js +++ b/lib/tiles/offlineEnabler.js @@ -224,7 +224,10 @@ define([ layer.loadFromFile = function(file, callback) // callback(success,msg) { + console.log("reading",file); + var store = this.offline.store; + var layer = this; if (window.File && window.FileReader && window.FileList && window.Blob) { @@ -246,16 +249,23 @@ define([ url: pair[0], img: pair[1] } + console.log("read",tile.url); store.add(tile,function(success) { + console.log("."); + if( success ) tileCount += 1; if( tileCount == tiles.length-1) + { + console.log("finished!"); + window.setTimeout(function() { /* refresh layer by zooming in and out, or some way that really refreshes the layer */ }, 1000); callback(true, tileCount + " tiles loaded from " + file.name); + } }); } - } + }; reader.readAsText(file); } else diff --git a/samples/tiles/tiles-indexed-db.html b/samples/tiles/tiles-indexed-db.html index 2bd1e72..a4f8eed 100644 --- a/samples/tiles/tiles-indexed-db.html +++ b/samples/tiles/tiles-indexed-db.html @@ -35,7 +35,7 @@ - JS Offline Mapping + JS Offline Mapping esri - - + +
diff --git a/samples/tiles/tiles-indexed-db.js b/samples/tiles/tiles-indexed-db.js index 2c5d98a..ac1fcb2 100644 --- a/samples/tiles/tiles-indexed-db.js +++ b/samples/tiles/tiles-indexed-db.js @@ -9,7 +9,7 @@ var showTiles = false; require(["esri/map", "esri/layers/GraphicsLayer", "esri/graphic", "esri/symbols/SimpleFillSymbol", "esri/dijit/Scalebar", "esri/arcgis/utils", "esri/geometry", - "dojo/dom", "dojo/on", "dojo/query", + "dojo/dom", "dojo/on", "dojo/query", "vendor/bootstrap-map-js/src/js/bootstrapmap", "esri/urlUtils", "esri/geometry/webMercatorUtils", "tiles/offlineEnabler", @@ -376,6 +376,12 @@ require(["esri/map", function loadFromFile() { var selectedFile = dojo.byId('file-select').files[0]; + + // clear input.files variable, so that next time it is empty again + // otherwise selecting the same file twice will not trigger the 'change' event the second time + var form = domConstruct.create('form'); + domConstruct.place(dojo.byId('file-select'), form, "before"); + form.reset(); if( !selectedFile ) {