Printing WebTileLayer with a custom tiling scheme

426
6
01-23-2024 07:46 PM
Lerman
by
Occasional Contributor

Hello Everyone,

When using the WebTileLayer to load third-party tiles, if the tiling scheme used by the third-party tiles is not the ArcGIS Online/Bing Maps/Google Maps (Web Mercator) tiling scheme, it is necessary to specify the tileInfo information when instantiating the WebTileLayer so that the service can be loaded correctly.

The current issue is that when printing this layer, the tileInfo information is not included in the print request parameters. If the tileInfo information is not included, ArcGIS Server will default to assuming that the layer uses the ArcGIS Online/Bing Maps/Google Maps (Web Mercator) tiling scheme. It will then calculate the tile row and column numbers based on this assumption to retrieve data, ultimately causing a significant offset in the printed map.

I believe this is a product bug. I would like to know if there is any code that can be modified to resolve this issue.

Thank you!

0 Kudos
6 Replies
JoelBennett
MVP Regular Contributor

According to the ExportWebMap specification (search for "Syntax for WebTiledLayer"), including tileInfo for a WebTileLayer is optional, and you are correct in that the tileInfo is not included for WebTileLayers by the esri/rest/print module.  I figure you have at least 2 options:

1) If you host the SDK locally, you could modify the esri/rest/print module to include the tileInfo.  Within that file, the code in question looks like this for 4.28:

function sa(a) {
    const b = {
        type: "WebTiledLayer",
        urlTemplate: a.urlTemplate?.replace(/\${/g, "{"),
        credits: a.copyright
    };
    a.subDomains && 0 < a.subDomains.length && (b.subDomains = a.subDomains);
    return b
}

 It would be easy to insert a line between 7 and 8 that includes the tileIInfo.

2) The approach most likely to be recommended would be to use a RequestInterceptor (via esriConfig.request) to intercept the request and add the tileInfo before it gets sent to the server.

Lerman
by
Occasional Contributor

@JoelBennett 

Thank you for the two solutions you provided. The first solution is easier to implement; by modifying the code in the screenshot to

function sa(a) {
        const b = {
            type: "WebTiledLayer", 
            urlTemplate: a.urlTemplate?.replace(/\${/g, "{"), 
            credits: a.copyright, 
            tileInfo:a.tileInfo
        };
        a.subDomains && 0 < a.subDomains.length && (b.subDomains = a.subDomains);
        return b
    }

I can include tileinfo information for layers in the print request. I appreciate your help.

However, I've encountered a second bug. Despite including tileinfo in the print request, ArcGIS Server is not reading the tileinfo information. I have confirmed that there is no issue with the modified print request parameters; the problem lies in ArcGIS Server not reading this parameter.

0 Kudos
JoelBennett
MVP Regular Contributor

I'm guessing that simply supplying the layer's tileInfo as is may not be the format expected.  The aforementioned documentation doesn't give the structure of the object, and simply says "For more information on tileInfo, see the ArcGIS REST API."  However, it's not clear where to go from there to find structure for the tileInfo.

I'm guessing that the output is supposed to be in the format discussed here.  In that case, there's a good chance that simply calling the tileInfo object's toJSON method will give you what you need.

0 Kudos
Lerman
by
Occasional Contributor

Thank you @JoelBennett !

I use the TileInfo.toJSON() method in the program to obtain a TileInfo object. I then compare this object with the TileInfo in the printed request parameters and find that the two are exactly the same.

0 Kudos
JoelBennett
MVP Regular Contributor

Ok...in this case, it seems like the client-side is doing what it should and that the problem is likely on the server-side.  If you have access to ArcGIS Server Manager, you might check the logs to see if they're showing anything.  Otherwise, I suppose the next course of action would be to take it up with technical support.

0 Kudos
Lerman
by
Occasional Contributor

Thank you @JoelBennett !

When specifying tileinfo, ArcGIS Server disregards the provided tileinfo, resulting in the absence of any error or warning information related to printing in the ArcGIS Server logs. I had previously reported this issue to Esri Support, but the communication was not smooth. I believe the technical capabilities of the Support analyst are not as proficient as those in the Esri Community, so I am resubmitting the issue here.

I present this issue with two objectives in mind. The first objective is to inquire if there are any temporary solutions; I believe you may have already provided a solution. The second objective is to hope that Esri analysts can see this problem and categorize it as an API bug. When the tiling scheme used by a tiled layer differs from the tiling scheme of ArcGIS Online, it is essential to include tileinfo information in the print request. Despite currently including tileinfo information in the print request, it is still not being printed as expected. I believe this might be a second bug.