From cbf89576749196e51a72907f46982feed282adf1 Mon Sep 17 00:00:00 2001 From: Daniel Dormont Date: Mon, 7 Oct 2024 09:18:33 -0400 Subject: [PATCH] Fix withcredentials identify (#1) * pass withCredentials to identify request if applicable * need to pass it one more place * remove dummy code --------- Co-authored-by: dandormont --- spec/Layers/FeatureLayer/FeatureManagerSpec.js | 3 ++- spec/Services/ServiceSpec.js | 5 +++-- src/Layers/DynamicMapLayer.js | 6 +++++- src/Layers/FeatureLayer/FeatureManager.js | 2 +- src/Tasks/IdentifyFeatures.js | 5 +++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/spec/Layers/FeatureLayer/FeatureManagerSpec.js b/spec/Layers/FeatureLayer/FeatureManagerSpec.js index e6e1783e6..652845fea 100644 --- a/spec/Layers/FeatureLayer/FeatureManagerSpec.js +++ b/spec/Layers/FeatureLayer/FeatureManagerSpec.js @@ -1263,7 +1263,8 @@ describe('L.esri.FeatureManager', function () { 'http://gis.example.com/mock/arcgis/rest/services/MockService/MockFeatureServer/0/query?returnGeometry=true&where=1%3D1&outSR=4326&outFields=*&inSR=4326&geometry=%7B%22xmin%22%3A-122.6513671875%2C%22ymin%22%3A45.49094569262732%2C%22xmax%22%3A-122.607421875%2C%22ymax%22%3A45.521743896993634%2C%22spatialReference%22%3A%7B%22wkid%22%3A4326%7D%7D&geometryType=esriGeometryEnvelope&spatialRel=esriSpatialRelIntersects&geometryPrecision=6&resultOffset=0&resultType=tile&f=geojson', JSON.stringify({ type: 'FeatureCollection', - features: [feature7] }) + features: [feature7] + }) ); var layer = new MockLayer({ diff --git a/spec/Services/ServiceSpec.js b/spec/Services/ServiceSpec.js index 3611fe2f7..2a392bf78 100644 --- a/spec/Services/ServiceSpec.js +++ b/spec/Services/ServiceSpec.js @@ -84,8 +84,9 @@ describe('L.esri.Service', function () { }); it('should fire a requestend event', function (done) { - server.respondWith('GET', 'http://services.arcgis.com/mock/arcgis/rest/services/MockService/route?foo=bar&f=json', JSON.stringify({ foo: 'bar' - })); + server.respondWith('GET', 'http://services.arcgis.com/mock/arcgis/rest/services/MockService/route?foo=bar&f=json', + JSON.stringify({ foo: 'bar' } + )); service.on('requestend', function (e) { expect(e.type).to.equal('requestend'); diff --git a/src/Layers/DynamicMapLayer.js b/src/Layers/DynamicMapLayer.js index 96efca2e8..09680494a 100644 --- a/src/Layers/DynamicMapLayer.js +++ b/src/Layers/DynamicMapLayer.js @@ -112,7 +112,11 @@ export var DynamicMapLayer = RasterLayer.extend({ } } - identifyRequest.run(callback); + identifyRequest.run(callback, { + options: { + withCredentials: !!this.options.withCredentials + } + }); // set the flags to show the popup this._shouldRenderPopup = true; diff --git a/src/Layers/FeatureLayer/FeatureManager.js b/src/Layers/FeatureLayer/FeatureManager.js index f210ad7e6..8744befed 100644 --- a/src/Layers/FeatureLayer/FeatureManager.js +++ b/src/Layers/FeatureLayer/FeatureManager.js @@ -266,7 +266,7 @@ export var FeatureManager = FeatureGrid.extend({ query = query.offset(offset); } - query.params['resultType'] = 'tile'; + query.params.resultType = 'tile'; if (this.options.requestParams) { Util.extend(query.params, this.options.requestParams); diff --git a/src/Tasks/IdentifyFeatures.js b/src/Tasks/IdentifyFeatures.js index d50ccad57..4b6c4a6dc 100644 --- a/src/Tasks/IdentifyFeatures.js +++ b/src/Tasks/IdentifyFeatures.js @@ -1,6 +1,7 @@ import { latLng } from 'leaflet'; import { Identify } from './Identify'; -import { responseToFeatureCollection, +import { + responseToFeatureCollection, boundsToExtent, _setGeometry } from '../Util'; @@ -67,7 +68,7 @@ export var IdentifyFeatures = Identify.extend({ } callback.call(context, undefined, featureCollection, response); } - }); + }, context); }, _setGeometryParams: function (geometry) {