Search our website

From the blog

Printing Web Maps with Discover Services

Author · Scott Davis
Published · Feb 2, 2017
Last modified · Mar 20, 2024
Category · Developer
Read time · 3 min

Export Web Map Tool

The Export Web Map, opens in a new tab tool is a geoprocessing tool that comes published as a service, opens in a new tab (Utilities/PrintingTools) out of the box with ArcGIS Server. From ESRI’s docs:

This tool takes the state of a web application (for example, included services, layer visibility settings, and client-side graphics) and returns a printable page layout or basic map of the specified area of interest.

This is most commonly used as a print service for web applications allowing the user to download a PDF of the current map extent.

The Problem

UGRC’s base map services (including the Google imagery) are hosted as WMTS services on discover.agrc.utah.gov. In order to use them an organization needs to register and request a quad-word. To prevent unauthorized use they are each locked down to a specific domain or set of domains. So if someone tries to use your quad-word from any other domain or server, the request is blocked. This all works well until you send a web map to the PrintingTools service in ArcGIS Server. The web map contains URLs to Discover services that have quad-words locked down to your web app’s domain. When the service requests tiles, it does so from the server that is hosting the service, not the browser. This causes Discover to reject the request because the origin of the request does not match what the quad-word is locked down to.

The Solution

To work around this issue, UGRC developed a Google Cloud function, opens in a new tab called serverless-print-proxy, opens in a new tab. Our proxy service takes the same parameters as Esri’s Export Web Map. When it receives a request, it swaps out any locked-down quad-words with wide open quad-words. Then it simply passes on the request to your Export Web Map service and passes back the response stripped of the wide open quad-words for security. You can read more about how we built serverless-print-proxy in our blog post about it. To get started, you need to get your account added to accounts.js, opens in a new tab. You can do this by submitting a pull request, opens in a new tab or by contacting Scott Davis from UGRC at stdavis@utah.gov.

Why don’t I just use a wide open quad-word in the first place? That’s a great question. I’m glad you asked! Using wide open quad-words in web applications would violate the Organizational Usage Agreement, opens in a new tab. It would be very easy for a savvy web developer to get your quad-words and use them on their own site.

UGRC’s serverless-print-proxy is open source and available for download and deployment to your own Google Cloud Platform account via: https://github.com/agrc/serverless-print-proxy, opens in a new tab. Feedback and pull requests are welcome.