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

DynamicMapLayer and Proxy JSON returned results in Proxy Request ?undefined #1153

Closed
larotech opened this issue Jun 5, 2019 · 3 comments
Closed
Assignees

Comments

@larotech
Copy link

larotech commented Jun 5, 2019

  • Browser and version:
    Chrome Version 71.0.3578.98

  • Version of Leaflet (L.version):
    1.5.1

  • Version of esri Leaflet (L.esri.VERSION):
    v2.2.4 - Wed Mar 20 2019 16:03:22 GMT-0700 (Pacific Daylight Time)

  • ArcGIS Version
    10.31

Steps to reproduce the error:

We have two ArcGIS Server environments, one for DEV and one for PROD.
The DEV MapService reports: Supports Dynamic Layers: false
The PROD MapService reports: Supports Dynamic Layers: true

The MapService Layer '19' is being shown using:

L.esri.dynamicMapLayer({
                    url: overlayUrl,
                    proxy: "/proxy.ashx",
                    opacity: 1,
                    useCors: true,
                    layers: [19],
                    transparent: true,
                    format: 'png32'
                }).addTo(map);

When the overlayUrl is pointing to the MapService in DEV which has "Supports Dynamic Layers: false" the JSON output contains a parameter called "href" which contains the url to the export image.

When the overlayUrl is pointing to the MapService in PROD which has "Supports Dynamic Layers: true" the JSON output contains a parameter called "imageData" which is a base64 encode of the export image.

The ESRI Leaflet JavaScript code at:

if (this.options.proxy) {
assumes there is an output property in the returned JSON called "href" which in the case of my MapService in PROD, its not returning an "href" but instead an "imageData" property containing a base64 image. What happens in this case is this._renderImage is passed a value of undefined which results in a request of /proxy.ashx?undefined

I propose a check for response.href or something similar to get around this issue:

if (this.options.proxy && response.href) {
          response.href = this.options.proxy + '?' + response.href;
        }
        if (response.href) {
          this._renderImage(response.href, bounds);
        } else {
          this._renderImage(response.imageData, bounds, response.contentType);
        }

This would then allow the renderImage method to look at response.imageData as href == undefined. This issue only happens for resources that need to be passed thru a proxy.

Regards,
Chris

@jgravois
Copy link
Contributor

jgravois commented Jun 5, 2019

related: #847

@patrickarlt
Copy link
Contributor

@gavinr it looks like

if (this.options.proxy) {
just needs to be changed to if (this.options.proxy && response.href) { as @larotech suggested. Assigning this to us to handle.

@larotech your suggested fix looks good. If you want to PR it that will help move things along faster.

@jwasilgeo
Copy link
Contributor

jwasilgeo commented Oct 9, 2019

Resolved in PR #1164. Thanks @crb04c and @larotech!

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

No branches or pull requests

5 participants