Hi Esri Community,
We run into a problem, We generate the Custom Maps and try to implement the "Print" API with "Print Templates" that listed in documentation here:
https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-print.html
When we implement the JavaScript Request but it's give Error "(index):23 Uncaught ReferenceError: execute is not defined"
I checked the Documentation and there is noting to add anything in the Require for Execute.
Here is the Code Example that we are using:
<link rel="stylesheet" href="https://js.arcgis.com/4.20/esri/themes/light/main.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://js.arcgis.com/4.20/"></script>
require([
"esri/config",
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"esri/layers/MapImageLayer",
"esri/identity/OAuthInfo",
"esri/identity/IdentityManager",
"esri/Basemap",
"esri/layers/VectorTileLayer",
"esri/layers/TileLayer",
"esri/rest/print",
"esri/rest/support/PrintTemplate",
"esri/rest/support/PrintParameters",
"esri/tasks/QueryTask",
"esri/rest/query"
], function(esriConfig, Map, MapView, FeatureLayer, MapImageLayer, OAuthInfo, esriId, Basemap, VectorTileLayer, TileLayer, Print, PrintTemplate, PrintParameters, QueryTask, Query) {
We create our Maps like this:
// Income Map
var map = new Map({ basemap: "arcgis-topographic" });
var view = new MapView({ map: map, center: [-94.7148669, 38.9065419], zoom: 14, container: "viewDiv2" });
const income_main = new MapImageLayer({ portalItem: { id: "ID" } });
map.add(income_main);
esriConfig.request.interceptors.push({ urls: Zipcode_Layer, before: function (params) {
params.requestOptions.query = params.requestOptions.query || {};
params.requestOptions.query.token = access_token; },});
var zipcode = new FeatureLayer({
url: Zipcode_Layer
});
map.add(zipcode);
After Map Creation we implement this code for Print API:
var url55 = "https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task/execute";
const template = new PrintTemplate({
format: "png",
exportOptions: {
dpi: 300
},
layout: "a4-portrait",
layoutOptions: {
titleText: "Gillette Stadium",
authorText: "Thomas"
}
});
const params = new PrintParameters({
view: view,
template: template
});
// execute(url50, params).then(printResult).catch(printError);
execute(url55, params).then(printResult).catch(printError);
But it's give an error "(index):23 Uncaught ReferenceError: execute is not defined" Is there anyone who can help to fix the problem...
Thank You