Select to view content in your preferred language

Problem accessing custom text elements in my print service

3502
12
Jump to solution
06-05-2013 12:53 PM
TracySchloss
Honored Contributor
I created a copy of the basic exportmaptemplates to make my own custom layout.  I needed to add both subtitles and descriptive text to my layout.  I added two new text elements and gave them element names of subTitleText and descripText.  Just to have something to see on my map, because I'm going to change these programmatically, I've given them a text value the same as the element name.

I didn't receive any errors when I published this print service, so I'm thinking the service itself is OK?  I'm having some problems with the syntax of referencing these new elements.

I'm using the JS API, and in Firebug, I can see the call getting made to the print service.  It includes the custom text elements by their element names, with the values that got assigned in my code.  I am getting an error in my JS code, but if I copy/paste the string that's getting submitted to the print URL, it does generate output.  It just doesn't include the new values I'm assigning for subTitleText and descripText.  It's still just the default string I put in as a placeholder.

 {"mapOptions":{"showAttribution":true,"extent":{"xmin":-10391169.27082235,"ymin":4469925.719133955,"xmax":-10383726.21519309,"ymax":4476250.883224546,"spatialReference":{"wkid":102100}},"spatialReference":{"wkid":102100},"scale":36111.90964300888},"operationalLayers":[{"id":"streetMap","title":"streetMap","opacity":1,"minScale":591657527.591555,"maxScale":1128.497176,"url":"http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"},{"id":"countyLayer","title":"countyLayer","opacity":1,"minScale":0,"maxScale":0,"url":"https://ogitest.oa.mo.gov/ArcGIS/rest/services/BaseMap/county_simple/MapServer","visibleLayers":null,"layers":[]},{"id":"status_stateOwnParcelLayer","title":"status_stateOwnParcelLayer","opacity":1,"minScale":0,"maxScale":0,"url":"https://ogitest.oa.mo.gov/ArcGIS/rest/services/StateOwnedParcels/MapServer","visibleLayers":null,"layers":[]},{"id":"allParcelLayer","title":"allParcelLayer","opacity":1,"minScale":0,"maxScale":0,"url":"https://ogitest.oa.mo.gov/ArcGIS/rest/services/allParcels/MapServer","visibleLayers":null,"layers":[]},{"id":"stateOwnFeaturelayer","url":"https://ogitest.oa.mo.gov/ArcGIS/rest/services/StateOwnedParcels/MapServer/1","title":"stateOwnFeaturelayer","minScale":1155581,"maxScale":0,"layerDefinition":{"drawingInfo":{"renderer":{"type":"simple","label":"","description":"","symbol":{"color":[255,211,127,255],"outline":{"color":[110,110,110,255],"width":0.4,"type":"esriSLS","style":"esriSLSSolid"},"type":"esriSFS","style":"esriSFSSolid"}}}}},{"id":"mapDiv_graphics","minScale":0,"maxScale":0,"featureCollection":{"layers":[{"layerDefinition":{"name":"polygonLayer","geometryType":"esriGeometryPolygon"},"featureSet":{"geometryType":"esriGeometryPolygon","features":[{"geometry":{"rings":[[[-10387278.9405581,4472649.14459539],[-10387279.6215167,4472629.95429174],[-10387325.6367082,4472631.12368592],[-10387325.6625458,4472633.30616325],[-10387325.8529157,4472641.81899572],[-10387325.6180643,4472650.3308426],[-10387278.9405581,4472649.14459539]]],"spatialReference":{"wkid":102100}},"symbol":{"color":[33,237,254,13],"outline":{"color":[33,237,254,255],"width":2.25,"type":"esriSLS","style":"esriSLSSolid"},"type":"esriSFS","style":"esriSFSSolid"}}]}}]}}],"exportOptions":{"outputSize":[800,1100],"dpi":96},"layoutOptions":{"titleText":"just something","customTextElements":{"descripText":"BEG 192.1 FT S SE COR KANSAS & KEARNEY STS S 50 FT E 160 FT N 50 FT W TO BEG11/29/22 (EX W 20 FT)","subTitleText":" 2331 N KANSAS AVE"},"scaleBarOptions":{"metricUnit":"Kilometers","metricLabel":"km","nonMetricUnit":"Miles","nonMetricLabel":"mi"},"legendOptions":{"operationalLayers":[]}}}


Am I misunderstanding how to include these custom text elements?  Should they not be nested within the layoutOptions the way I have them?  Sorry about the big long JSON string, that's just the way it came out when I copied from Firebug.
Tags (2)
0 Kudos
12 Replies
MichaelVolz
Esteemed Contributor
Tracy:

For the web app you were building, were the items descripText and subTitleText being entered by the user at run-time just before the print is being created (maybe with text boxes or the HTML5/Javascript equivalent)?

Have you tried using customTextElements to place a selected records data from a query onto the print template?
0 Kudos
TracySchloss
Honored Contributor
In my final solution, I had all those elements incorporated.  The user has the opportunity to enter in a title and subtitle.  If they don't, I have default strings based on some variables I declared earlier, like the name of the county.

Generally the workflow is that the user has identified a particular feature, and details about it is what they want to appear in a printout.  I'm storing several variables from that task initially.  If they choose to enter their own title/subtitle, those will be used instead of the variables I've stored.    For the custom text, I'm pulling data from multiple attributes and concatenating them into a single string.  That's what I'm using to populate the customTextElement that I'd previous defined in my custom print template.
0 Kudos
MichaelVolz
Esteemed Contributor
Tracy:

From what I've read and experimented with, it seems that the customTextElements are set at start-up when the application is reading through the available print templates in the print service.  Since the enduser has not set the information for the customTextElements yet, do you need to trap the exportwebmap_as_json before it goes to the print service so you can substitute the customTextElements set at start-up with the variables that the user has defined in the application since start-up?

I setup the customTextElement to read the value from a textbox where the user enters a value, but the print template was always only using the default value for this textbox that is available at start-up.
0 Kudos