From 85855090b5f3b01d5d42ece54b51b4f2604aab50 Mon Sep 17 00:00:00 2001 From: jwasilgeo Date: Fri, 17 Jan 2020 14:28:33 -0600 Subject: [PATCH 1/3] added 2 new debug html pages for testing --- .gitignore | 2 + debug/sample-dynamic-map-layer.html | 83 +++++++++++++++++++++++++++++ debug/sample-image-map-layer.html | 83 +++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 debug/sample-dynamic-map-layer.html create mode 100644 debug/sample-image-map-layer.html diff --git a/.gitignore b/.gitignore index bd1919c2a..673efb9a7 100644 --- a/.gitignore +++ b/.gitignore @@ -33,6 +33,8 @@ debug/*.js debug/*.json debug/archive/ !debug/sample.html +!debug/sample-dynamic-map-layer.html +!debug/sample-image-map-layer.html # Docs Build site/build diff --git a/debug/sample-dynamic-map-layer.html b/debug/sample-dynamic-map-layer.html new file mode 100644 index 000000000..48431d59c --- /dev/null +++ b/debug/sample-dynamic-map-layer.html @@ -0,0 +1,83 @@ + + + + + + Esri Leaflet Debugging Sample + + + + + + + + + + + + + + +
+
+ +
+ + + + + + \ No newline at end of file diff --git a/debug/sample-image-map-layer.html b/debug/sample-image-map-layer.html new file mode 100644 index 000000000..a5e815a90 --- /dev/null +++ b/debug/sample-image-map-layer.html @@ -0,0 +1,83 @@ + + + + + + Esri Leaflet Debugging Sample + + + + + + + + + + + + + + +
+
+ +
+ + + + + + \ No newline at end of file From 07c2ee5431622a1dac83eb971be66538629ca1d0 Mon Sep 17 00:00:00 2001 From: jwasilgeo Date: Fri, 17 Jan 2020 14:37:14 -0600 Subject: [PATCH 2/3] updated DynamicMapLayer and ImageMapLayer: - removed options.f conditional override during initialization of DynamicMapLayer (related to #1180); - standardized usage of params.token and params.proxy in "_buildExportParams" and "_requestExport" of DynamicMapLayer and ImageMapLayer; - prepended optional params.proxy in "_requestExport" of DynamicMapLayer and ImageMapLayer; --- src/Layers/DynamicMapLayer.js | 28 +++++++++++++++++++--------- src/Layers/ImageMapLayer.js | 29 ++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/Layers/DynamicMapLayer.js b/src/Layers/DynamicMapLayer.js index 5b82132c4..5f909f4a5 100644 --- a/src/Layers/DynamicMapLayer.js +++ b/src/Layers/DynamicMapLayer.js @@ -20,10 +20,6 @@ export var DynamicMapLayer = RasterLayer.extend({ this.service = mapService(options); this.service.addEventParent(this); - if ((options.proxy || options.token) && options.f !== 'json') { - options.f = 'json'; - } - Util.setOptions(this, options); }, @@ -179,12 +175,16 @@ export var DynamicMapLayer = RasterLayer.extend({ this.service.request('export', params, function (error, response) { if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire - if (this.options.token && response.href) { - response.href += ('?token=' + this.options.token); + if (params.token && response.href) { + // append token + response.href += ('?token=' + params.token); } - if (this.options.proxy && response.href) { - response.href = this.options.proxy + '?' + response.href; + + if (params.proxy && response.href) { + // prepend proxy + response.href = params.proxy + '?' + response.href; } + if (response.href) { this._renderImage(response.href, bounds); } else { @@ -192,8 +192,18 @@ export var DynamicMapLayer = RasterLayer.extend({ } }, this); } else { + // if not 'json', then 'image' is the only other valid value for params.f + // (this.options.f should be equal to 'image' if the default 'json' value was not used) params.f = 'image'; - this._renderImage(this.options.url + 'export' + Util.getParamString(params), bounds); + + var url = this.options.url + 'export' + Util.getParamString(params); + + if (params.proxy) { + // prepend proxy + url = params.proxy + '?' + url; + } + + this._renderImage(url, bounds); } } }); diff --git a/src/Layers/ImageMapLayer.js b/src/Layers/ImageMapLayer.js index 0f4846964..8791ca7b6 100644 --- a/src/Layers/ImageMapLayer.js +++ b/src/Layers/ImageMapLayer.js @@ -165,6 +165,10 @@ export var ImageMapLayer = RasterLayer.extend({ params.token = this.service.options.token; } + if (this.options.proxy) { + params.proxy = this.options.proxy; + } + if (this.options.renderingRule) { params.renderingRule = JSON.stringify(this.options.renderingRule); } @@ -180,17 +184,32 @@ export var ImageMapLayer = RasterLayer.extend({ if (this.options.f === 'json') { this.service.request('exportImage', params, function (error, response) { if (error) { return; } // we really can't do anything here but authenticate or requesterror will fire - if (this.options.token) { - response.href += ('?token=' + this.options.token); + + if (params.token) { + // append token + response.href += ('?token=' + params.token); } - if (this.options.proxy) { - response.href = this.options.proxy + '?' + response.href; + + if (params.proxy) { + // prepend proxy + response.href = params.proxy + '?' + response.href; } + this._renderImage(response.href, bounds); }, this); } else { + // if not 'json', then 'image' is the only other valid value for params.f + // (this.options.f should be equal to 'image' if the optional 'json' value was not used) params.f = 'image'; - this._renderImage(this.options.url + 'exportImage' + Util.getParamString(params), bounds); + + var url = this.options.url + 'exportImage' + Util.getParamString(params); + + if (params.proxy) { + // prepend proxy + url = params.proxy + '?' + url; + } + + this._renderImage(url, bounds); } } }); From 49b0a9fbd041d66de69bfd2ed086ee162163bf00 Mon Sep 17 00:00:00 2001 From: jwasilgeo Date: Fri, 17 Jan 2020 16:47:19 -0600 Subject: [PATCH 3/3] added another sample page to test dynamic map layer with server auth workflow style --- .gitignore | 1 + .../sample-dynamic-map-layer-server-auth.html | 103 ++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 debug/sample-dynamic-map-layer-server-auth.html diff --git a/.gitignore b/.gitignore index 673efb9a7..1dcdf6fba 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ debug/*.json debug/archive/ !debug/sample.html !debug/sample-dynamic-map-layer.html +!debug/sample-dynamic-map-layer-server-auth.html !debug/sample-image-map-layer.html # Docs Build diff --git a/debug/sample-dynamic-map-layer-server-auth.html b/debug/sample-dynamic-map-layer-server-auth.html new file mode 100644 index 000000000..4e6fcb9de --- /dev/null +++ b/debug/sample-dynamic-map-layer-server-auth.html @@ -0,0 +1,103 @@ + + + + + + Esri Leaflet Debugging Sample + + + + + + + + + + + + + + +
+
+ +
+ + + + + + \ No newline at end of file