use of proxy is now optional

This commit is contained in:
Javier Abadia 2014-02-25 10:02:30 +01:00
parent 0045ddc41d
commit 2dd59fe281
2 changed files with 15 additions and 2 deletions

View File

@ -366,7 +366,7 @@ define([
layer.estimateTileSize = function(callback)
{
if(layer._lastTileUrl){
var url = this.offline.proxyPath + "?" + layer._lastTileUrl;
var url = this.offline.proxyPath? this.offline.proxyPath + "?" + layer._lastTileUrl : layer._lastTileUrl;
request.get(url,{
handleAs: "text/plain; charset=x-user-defined",
headers: {
@ -413,7 +413,7 @@ define([
url = url.split('?')[0];
/* download the tile */
var imgurl = this.offline.proxyPath + "?" + url;
var imgurl = this.offline.proxyPath? this.offline.proxyPath + "?" + url : url;
var req = new XMLHttpRequest();
req.open("GET", imgurl, true);
req.overrideMimeType("text/plain; charset=x-user-defined"); // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest?redirectlocale=en-US&redirectslug=DOM%2FXMLHttpRequest%2FUsing_XMLHttpRequest#Handling_binary_data

View File

@ -187,6 +187,7 @@
<button id="show-stored-tiles" type="button" class="btn btn-default"><i class="fa fa-th"></i> <span id="show-stored-tiles-caption">Show Stored Tiles</span></button>
<button id="save-file" type="button" class="btn btn-default"><i class="fa fa-download"></i> Save to File</button>
<span id="load-file" type="button" class="btn btn-default"><i class="fa fa-upload"></i> Load from File <input type="file" id="file-select" name="file-select"></span>
<button id="use-proxy" type="button" class="btn btn-default"> Using proxy: <span id="using-proxy">Yes</span></button>
</div>
</div>
<div id="downloading-ui">
@ -436,6 +437,7 @@ require(["esri/map",
on(dojo.byId('show-stored-tiles'),'click', toggleShowStoredTiles);
on(dojo.byId('save-file'),'click', saveToFile);
on(dojo.byId('file-select'),'change', loadFromFile);
on(dojo.byId('use-proxy'),'click', toggleProxy);
dojo.byId('go-online-btn').style.display = "none";
esri.show(dojo.byId('ready-to-download-ui'));
esri.hide(dojo.byId('downloading-ui'));
@ -451,6 +453,7 @@ require(["esri/map",
esri.hide(dojo.byId('go-online-btn'));
dojo.byId('update-offline-usage').disabled = true;
dojo.byId('show-stored-tiles').disabled = true;
dojo.byId('use-proxy').disabled = true;
esri.hide(dojo.byId('downloading-ui'));
showAlert("alert-danger","Failed initializing storage, probably your browser doesn't support <a href='http://caniuse.com/#feat=indexeddb'>IndexedDB</a> nor <a href='http://caniuse.com/#feat=sql-storage'>WebSQL</a>");
@ -709,6 +712,16 @@ require(["esri/map",
});
}
function toggleProxy()
{
if( basemapLayer.offline.proxyPath !== null )
basemapLayer.offline.proxyPath = null;
else
basemapLayer.offline.proxyPath = window.proxyPath || "../lib/proxy.php";
dojo.byId('using-proxy').innerHTML = basemapLayer.offline.proxyPath? "Yes" : "No";
}
function showAlert(type, msg)
{
var icon = "";