Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic layer cannot use both f:image and token #1180

Closed
jptheripper opened this issue Jan 15, 2020 · 14 comments
Closed

Dynamic layer cannot use both f:image and token #1180

jptheripper opened this issue Jan 15, 2020 · 14 comments
Assignees
Labels

Comments

@jptheripper
Copy link

  • Browser and version:

Chrome 51

  • Version of Leaflet (L.version):

0.7.7, 1.0.0?

  • Version of esri Leaflet (L.esri.VERSION):

1.0.4, 2.0.3, master?

Steps to reproduce the error:

  1. create map
  2. add server authenticated service that requires password.
  3. add parameter f:'json'
  4. add parameter token: response.token

What happens is the image parameter is ignored and request is sent with type f=json

I was expecting f=image to be respected. Feature service only loads half the time due to internal load balancer not having request on /arcgisoutput (which is why we need to use the f=image parameter)

https://jsbin.com/hiqequg/edit?html,output

@jwasilgeo
Copy link
Contributor

Some more background and historical info would be helpful here from previous contributors to ./src/Layers/DynamicMapLayer.js.

It appears to me that this is acting as designed in:

@jgravois
Copy link
Contributor

jgravois commented Jan 15, 2020

theelse block below needs an options.token check similar to the if block above it, except it needs to optionally append that value as a parameter to the original url.

} else {
params.f = 'image';
this._renderImage(this.options.url + 'export' + Util.getParamString(params), bounds);
}

besides the service in @jptheripper's jsbin, you can also test with the one below.

username: user1
password: user1

http://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire_secure_ac2/MapServer/export?token=foo&...

@jptheripper
Copy link
Author

This is absolutely perfect. We can confirm once this functionality is applied that f='image' and token work together as desired.

@jptheripper
Copy link
Author

Sorry, I am new to the whole process. How do we get the change applied to the source code?

@jgravois
Copy link
Contributor

How do we get the change applied to the source code?

pull requests are always welcome.

in this case, a new test similar to the one below would be extremely helpful.

it('should be able to request an image directly from the export service', function () {
layer = L.esri.dynamicMapLayer({
url: url,
f: 'image'
});
var spy = sinon.spy(layer, '_renderImage');
layer.addTo(map);
expect(spy.getCall(0).args[0]).to.match(new RegExp(/http:\/\/services.arcgis.com\/mock\/arcgis\/rest\/services\/MockMapService\/MapServer\/export\?bbox=-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+%2C-?\d+\.\d+&size=500%2C500&dpi=96&format=png24&transparent=true&bboxSR=3857&imageSR=3857&f=image/));
});

@jwasilgeo
Copy link
Contributor

@jgravois thanks for input. And what should we do to this block that overrides on construction?

if ((options.proxy || options.token) && options.f !== 'json') {
options.f = 'json';
}

@jptheripper
Copy link
Author

Yes I was about to comment that needs to be dealt with as well. image type should not be overridden just because there is a token or proxy

@jwasilgeo
Copy link
Contributor

jwasilgeo commented Jan 15, 2020

Should it be dropped altogether? Not sure what the original intent was. Thanks!

@jgravois
Copy link
Contributor

good catch @jwasilgeo. I forgot all about that.

to implement this new feature you'd need to remove the options.token check in the override.

if you want to take a stab at implementing the proxy logic for f: 'image' too, then you could get rid of it altogether.

Not sure what the original intent was.

maybe Pat figured that if folks wanted to work with secure layers they could just use f: 'json'.
I'm not sure.

@jptheripper
Copy link
Author

jptheripper commented Jan 16, 2020

In our test (we only use image, with and without token) simply commenting out the override worked for us. I imagine that may break other cases. Is it possible to just change the override to

if (((options.proxy || options.token) && options.f !== 'json')&&(!(options.token&& options.f == 'image'))) { options.f = 'json'; }

@jwasilgeo jwasilgeo self-assigned this Jan 17, 2020
jwasilgeo pushed a commit that referenced this issue Jan 17, 2020
- 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;
@jptheripper
Copy link
Author

So, (because i am new to all this), how long does this take to propagate into the CDN

@gavinr
Copy link
Contributor

gavinr commented Jan 27, 2020

@jptheripper in order for the fix in that Pull Request to become available for your use on the CDN, we must publish a new release. We intend to cut a new release soon.

@gavinr
Copy link
Contributor

gavinr commented Jan 29, 2020

@gavinr gavinr closed this as completed Jan 29, 2020
@timothycouchhsi
Copy link

Thanks a ton! This is great. And you were so quick to respond :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants