POST
|
Hello Reagan, I cannot post the entire solution, but the main snippets on labeling are shown below. I Hope it helps. PS: I replied to your email but the mail bounced back. Regards Ujjwal if (readyToPrint) { $.when(ExportMapOverview()).done(function () { $.when(AddPrintLayers(selectedPrintTemplate)).done(function () { showProgressBar(); $.when(OverlayMapGrid()).done(function () { setTimeout(TriggerPrintJob, 3000); //otherwise labels don't make it to the output! }); readyToPrint = false; }); }); } function PrepareLabellingInfo(lblFields) { if (lblFields.indexOf(",") > 0) { labelAttr = "CONCATENATE(["; $.each(lblFields.split(","), function (indx, val) { labelAttr += "$feature." + val.trim() + ","; }); labelAttr = labelAttr.slice(0, labelAttr.lastIndexOf(",")); labelAttr += "],',')"; //separator is ',' } else labelAttr = "$feature." + lblFields; } function TriggerPrintJob() { var printTemplateObj, printParams, printTaskObj; printTaskObj = new printTask(printGPTaskUrl + "?token=" + token); printTemplateObj = new printTemplate(); printParams = new printParameters(); printTemplateObj.exportOptions = { width: pageWidth, height: pageHeight, dpi: pageDpi }; printTemplateObj.format = "PNG32"; printTemplateObj.layout = "MAP_ONLY"; printParams.map = map; printParams.template = printTemplateObj; var Web_Map_as_JSON = printTaskObj._getPrintDefinition(map, printParams); delete Web_Map_as_JSON.operationalLayers[0].token; //add export options var expOptions = ', "exportOptions":{"outputSize":[' + pageWidth + ',' + pageHeight + '],"dpi":' + pageDpi + '}'; var strWebMapJson = JSON.stringify(Web_Map_as_JSON); Web_Map_as_JSON = strWebMapJson.slice(0, strWebMapJson.lastIndexOf('}')) + expOptions + '}'; var payLoad = { "Web_Map_as_JSON": Web_Map_as_JSON, "Format": "PNG32", "Layout_Template": "MAP_ONLY", "f": "json" }; //call execute endpoint via XHR $.ajax({ type: "POST", url: printGPTaskUrl + "?token=" + token, data: payLoad, success: printSuccess }); function printSuccess(result) { readyToPrint = false; var resultJson = JSON.parse(result); if (resultJson.error == null) {//success printImgSrc = resultJson.results[0].value.url; var printPageElements = '{' + '"templateName" : "' + selectedPrintTemplate + '",' + '"imageSource" : "' + printImgSrc + '",' + '"overviewImageSource" : "' + overviewImgSrc + '",' + '"mapExtents" : "' + map.extent.xmin + ';' + map.extent.ymin + ';' + map.extent.xmax + ';' + map.extent.ymax + '",' + '"mapScale" : "' + map.getScale() + '",' + ... '"remarks" : "' + document.getElementById("txtRemarks").value + '"' + '}'; localStorage.setItem("printPageElements", printPageElements); ShowPrintOutput(); $.when(RemovePrintLayers(selectedPrintTemplate)).done(function () { hideProgressBar(); }); } else { readyToPrint = false; alert("Error generating print!\nPlease contact administrator."); console.log("Error generating print - " + resultJson.error.message); $.when(RemovePrintLayers(selectedPrintTemplate)).done(function () { hideProgressBar(); }); } }
... View more
08-18-2020
09:11 PM
|
0
|
0
|
1771
|
POST
|
ESRI has released a new #arcade labeling engine which is still at early stages of development. Plus, there are functional differences between 3.x & 4.x versions of the Javascript API. As of now, #arcade does not support a lot of basic labeling features like LIKE queries, multi-line labels etc. Concatenation is also quite tricky though there is a CONCATENATE function available. A workaround could be to apply the definition expression on the layer and then label the filtered out features.
... View more
10-22-2018
04:54 AM
|
0
|
0
|
271
|
POST
|
So, removing the token from the WebMapAsJSON string and calling the execute URL using standard XHR did the trick! Attaching the code here for reference. Notice the use of undocumented function PrintTaskObject._getPrintDefinition(map, printParams). var Web_Map_as_JSON = printTaskObj._getPrintDefinition(map, printParams);
delete Web_Map_as_JSON.operationalLayers[0].token;
//add export options
var expOptions = ', "exportOptions":{"outputSize":[' + pageWidth + ',' + pageHeight + '],"dpi":' + pageDpi + '}';
var strWebMapJson = JSON.stringify(Web_Map_as_JSON);
Web_Map_as_JSON = strWebMapJson.slice(0, strWebMapJson.lastIndexOf('}')) + expOptions + '}';
var payLoad = {
"Web_Map_as_JSON": Web_Map_as_JSON,
"Format": "PNG32",
"Layout_Template": "MAP_ONLY",
"f": "json"
};
//call execute endpoint via XHR
$.ajax({
type: "POST",
url: printGPTaskUrl + "?token=" + token,
data: payLoad,
success: printSuccess
});
... View more
10-22-2018
04:48 AM
|
0
|
0
|
832
|
POST
|
Okay...so feature layers don't seem to support labels while printing. I turned on the relevant layers from the dynamic service using setVisibleLayers() and apply definition query/label expression using setDefinitionExpression() & setDynamicLayerInfos() respectively - and the labels appear beautifully in the print output!!! Regards UJ
... View more
10-22-2018
04:38 AM
|
2
|
2
|
1771
|
POST
|
Hi, I am trying to print secured services and it works fine for most of the part except that the labeling info does not show on the print output. While I am preparing the map, the labels do appear, but do not show up on print output. I am using ESRI JS API v3.25. var labelJson = { "labelExpressionInfo": { "expression": "" }, "useCodedValues": false, "labelPlacement": "" }; labelJson.labelExpressionInfo.expression = "CONCATENATE([$feature.NAME, $feature.CLASS], ' / ')"; labelJson.labelPlacement = "above-right"; var labelSymbol = new textSymbol(); var lblClass = new labelClass(labelJson); lblClass.symbol = labelSymbol; printFeatLyrEquipment.setLabelingInfo([lblClass]); //this is a Feature layer map.addLayer(printFeatLyrEquipment); Not sure why is it not printing the labels...any clues? Thanks in advance! ~UJ
... View more
10-17-2018
06:27 PM
|
0
|
8
|
2376
|
POST
|
Hi, ArcGIS Server Version: 10.4.0 ArcGIS JS API: 3.25 ArcGIS Desktop: 10.2.1 Browser: IE 11 In my web application, I am consuming secured services and have a requirement to print the map contents. Initially, the token expiry was set to default (i.e. 60 mins) and everything worked fine including printing, using the Utilities/PrintingTools GP Service. As part of the requirement, the token expiry was increased from 60 mins to 240 mins - everything still worked fine except for printing! Looking up the esri help it was clear I had to create a custom service. I created the custom service as described in the help documents, but it still fails with the following error: Error executing tool. Export Web Map Task Job ID: jb88972125ace4b6593c8055ee779e920 : Layer "dynLyrId": Unable to connect to map server at https://server.domain:6443/arcgis/rest/services/WebViewer/MapServer/. Failed to execute (Export Web Map). Failed to execute (Export Web Map Task). The custom service has a user connection (with saved credentials) embedded into it as required. Upon investigating further, I found out that if I remove the token from the WebMapAsJson, it works like a charm (in ArcCatalog at least)! I don't know how to do that as I am not creating the WebMapAsJson manually, but the esri JS API creates it while sending the request. I also tried to increase the ArcGIS Servers' shortTimeout value from 60 to 240 but even that failed. Any ideas to make the printing work with long-validity tokens? Regards Ujjwal
... View more
10-09-2018
03:02 AM
|
0
|
1
|
1272
|
POST
|
Hi Robert, Single word values work, try using "South Dakota" and you'll see what I mean. Other SQL expressions like LIKE, % also seem to fail. Regards Ujjwal
... View more
06-07-2018
11:12 PM
|
0
|
1
|
271
|
POST
|
Hi Robert, The example you've shown is for a dynamic map service, while I am working on a Feature layer. In my code, though it does not throw any error, but the labels dont show up. The same behavior can be seen in the ESRI sandbox, which you can access at: https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=layers_label This makes me believe that this is a possible bug in the Arcade labelling engine, because ESRI claims to honor any "valid" SQL in the where clause. Regards Ujjwal
... View more
06-07-2018
09:47 PM
|
0
|
3
|
735
|
POST
|
Is there a bug number for this where clause issue? It still does not work in v3.24
... View more
06-06-2018
10:43 PM
|
0
|
5
|
735
|
POST
|
Did anyone get past the new schema not visible in the post install drop-down? Nishi Mishra Any suggestions for the missing schema...only SDE is visible.
... View more
07-13-2016
02:33 AM
|
0
|
0
|
478
|
POST
|
Include the UI_TEXT keyword as one of the ##WMX keywords
... View more
07-13-2016
02:31 AM
|
0
|
0
|
460
|
POST
|
Yes, this random unregistering of the web adaptor is also a bug...I guess web adaptor software is full of bugs. Sent from Gmail mobile on Google Nexus 6
... View more
06-01-2016
07:26 AM
|
0
|
0
|
357
|
POST
|
Have you checked if the *ArcGISWebAdaptorAppPool *has read/write access to the web adaptor config? There's a bug with web adaptor - http://support.esri.com/en/bugs/nimbus/TklNMDgxNzM0
... View more
05-31-2016
09:28 PM
|
0
|
2
|
357
|
POST
|
Does anyone know if this WebAdaptor bug has been resolved at 10.4 or beyond?
... View more
05-30-2016
10:27 PM
|
0
|
0
|
357
|
POST
|
Hi, I am trying to re-project a lat/long co-ordinate using the GeometryServer > Project method. Though I am able to do it via REST endpoint, I am having issues trying to form the request in SOAP UI. I always get the Unable to instantiate class for xml schema type: SpatialReference error. This is how my SOAP UI request looks like: I also would like to know the format for the Geometry object, as here in this request I have 'guessed' it fro the corresponding REST URL. Regards Ujjwal
... View more
08-02-2015
07:32 PM
|
0
|
0
|
2800
|
Title | Kudos | Posted |
---|---|---|
2 | 10-22-2018 04:38 AM |
Online Status |
Offline
|
Date Last Visited |
07-27-2023
03:22 PM
|