POST
|
First off, are customTextElements even supported in API 3.29? I have a Print dijit set up (code below) but I can't seem to get the customTextElements to show up on my layout. The customTextElements come directly from the Get Layout Templates Info Execute task. I would really like to be able to pass an array that is defined in PHP but the print keeps timing out. I swapped the arrays to just the letter "t" to see if that would work and again, it's timing out. I see that customTextElements are listed under the layoutOptions but you can't pass DynamicText? I am looking to display attribute information for the feature that is being printed by a URL parameter (ID) on the layout template. // print dijit
var printer = new Print({
map: theMap,
url: "<server>",
templates: [{
label: "Map",
format: "PDF",
layout: "TREATMENTS",
layoutOptions: {
customTextElements: [
{"Target": "t"},
{"Date": "t"},
{"EPA": "t"},
{"Chemical": "t"},
{"Weather": "t"},
{"Title": "t"},
{"Year": "t"}
]
},
exportOptions: {
width: 772,
height: 772,
dpi: 200
}
}]
}, dom.byId("printButton"));
printer.startup();
... View more
08-09-2019
06:08 AM
|
0
|
17
|
1750
|
POST
|
Ken Buja and Ben Elan - I can't thank you enough for taking the time to look over my code and Ben, I was able to get a printout! I would have never figured out that the positioning of the "dojo/domReady!" module would have made a difference... At least I was close! I believe the "dojo/_base/json" that you pointed out Ken was left over from another printing process I was trying but had forgotten to remove it. I don't mean to bother you both with another question but now that I have a printout with the .png URL, can this print process be called in the background versus a button?
... View more
08-07-2019
05:27 AM
|
0
|
1
|
4004
|
POST
|
Hi Ben - thank you so much for clarifying this. It's strange but as soon as I add // print dijit
var printer = new Print({
map: map,
url: "https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
}, dom.byId("printButton"));
printer.startup(); it seems to bust my map and I get an error TypeError: dom.byId is not a function It's a bit long but below is what I have so far <html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>MISIN Treatment Tracker: Print</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.29/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.29/esri/css/esri.css">
<!--js scripts to print map-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.2/jspdf.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/javascript-canvas-to-blob/3.15.0/js/canvas-to-blob.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.js"></script>
<!--end print scripts-->
<style>
@media print {
#printButton {
display: none;
}
}
</style>
<!-- START ESRI MAP SCRIPT -->
<script>var dojoConfig = { parseOnLoad: true }</script>
<script src="https://js.arcgis.com/3.29/"></script>
<script>
var theMap;
var cred = "esri_jsapi_id_manager_data";
var symbol, infoTemplate;
var OID;
require([
"esri/map",
"esri/SpatialReference",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/FeatureLayer",
"esri/layers/ImageParameters",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/layers/LayerDrawingOptions",
"esri/layers/LabelLayer",
"esri/layers/LabelClass",
"esri/symbols/TextSymbol",
"esri/renderers/SimpleRenderer",
"esri/graphic",
"esri/InfoTemplate",
"esri/urlUtils",
"esri/arcgis/utils",
"esri/graphicsUtils",
"esri/dijit/Legend",
"esri/dijit/Scalebar",
"esri/dijit/Print",
"esri/tasks/query",
"esri/tasks/QueryTask",
"esri/tasks/PrintTask",
"esri/tasks/PrintParameters",
"esri/tasks/PrintTemplate",
"esri/request",
"esri/config",
"esri/geometry/Extent",
"esri/IdentityManager",
"esri/lang",
"dojo/_base/array",
"dojo/_base/Color",
"dojo/_base/unload",
"dojo/cookie",
"dojo/json",
"dojo/_base/json",
"dojo/parser",
"dojo/dom-construct",
"dojo/dom-class",
"dojo/dom",
"dojo/on",
"dojo/domReady!",
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"dijit/form/Button"
], function(
Map,
//MapView,
SpatialReference,
ArcGISTiledMapServiceLayer,
ArcGISDynamicMapServiceLayer,
FeatureLayer,
ImageParameters,
SimpleMarkerSymbol,
SimpleLineSymbol,
SimpleFillSymbol,
LayerDrawingOptions,
LabelLayer,
LabelClass,
TextSymbol,
SimpleRenderer,
Graphic,
InfoTemplate,
urlUtils,
arcgisUtils,
graphicsUtils,
Legend,
Scalebar,
Print,
Query,
QueryTask,
PrintTask,
PrintParameters,
PrintTemplate,
esriRequest,
esriConfig,
Extent,
esriId,
esriLang,
arrayUtils,
Color,
baseUnload,
cookie,
JSON,
parser,
domConstruct,
domClass,
dom,
on,
BorderContainer,
ContentPane,
Button
){
function init()
{
// store credentials/serverInfos before the page unloads
baseUnload.addOnUnload(storeCredentials);
// look for credentials in local storage
loadCredentials();
//parser.parse();
esriConfig.defaults.io.proxyUrl = "/proxy/";
// START OF ESRI WEBMAP CREATION
//create the map
theMap = new Map("mapdiv", {
basemap:"topo",
showLabels: true,
});
//Disable Map Navigation
theMap.on("load", function() {
theMap.disableMapNavigation();
theMap.hideZoomSlider();
});
// print dijit
var printer = new Print({
map: theMap,
url: "https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
}, dom.byId("printButton"));
printer.startup();
// Create labels for the National Wetlands Inventory Layer
var labelField = "WETLAND_TYPE"
var wetlandsColor = new Color ("#0E881B");
var wetlandsLine = new SimpleLineSymbol("solid", wetlandsColor, 1.5);
var wetlandsRenderer = new SimpleRenderer(wetlandsLine);
var wetlandsLabel = new TextSymbol().setColor(wetlandsColor);
wetlandsLabel.font.setSize("10pt");
wetlandsLabel.font.setFamily("arial");
var json = {
"labelExpressionInfo": {"value": "{WETLAND_TYPE}"}
};
//create instance of LabelClass (note: multiple LabelClasses can also be passed in as an array)
var labelClass = new LabelClass(json);
labelClass.symbol = wetlandsLabel;
//Add National Wetlands Inventory
var wetlands = new FeatureLayer("https://gisago.mcgi.state.mi.us/arcgis/rest/services/OpenData/hydro/MapServer/18");
wetlands.setRenderer(wetlandsRenderer)
wetlands.setLabelingInfo([ labelClass ]);
theMap.addLayer(wetlands);
//Use the ImageParameters to set map service layer definitions and map service visible layers before adding to the client map.
var imageParameters = new ImageParameters();
//only certain layers to be visible. This can only be done with a dynamic map service and it does impact performance. Cached map services are recommended.
imageParameters.layerIds = [2];
imageParameters.layerOption = ImageParameters.LAYER_OPTION_SHOW;
imageParameters.transparent = true;
//construct ArcGISDynamicMapServiceLayer with imageParameters from above
var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("https://fuzzy.asets.msu.edu/arcgis/rest/services/MISIN/misin_treatments/MapServer",
{"opacity": 0.0},
{"imageParameters": imageParameters});
theMap.addLayer(dynamicMapServiceLayer);
//build query task
var queryTask = new QueryTask("https://fuzzy.asets.msu.edu/arcgis/rest/services/MISIN/misin_treatments/MapServer/2");
//build query filter
var query = new Query();
query.returnGeometry = true;
query.outFields = ["*"];
//create symbol for selected features
symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([64,124,248]), 2),new dojo.Color([189,209,253]));
//pass the url parameters.
var urlObject = urlUtils.urlToObject(window.location.href);
if (urlObject.query)
{
if (urlObject.query.id)
{ OID = urlObject.query.id; }
//set query based on the parameters
var treatmentid = "OBJECTID = '" + OID + "'";
query.where = treatmentid;
//execute query and call showResults on completion
//queryTask.execute(query,showResults);
}
//Execute task and call showResults on completion
queryTask.execute(query, showResults);
}
function showResults(featureSet)
{
//remove all graphics on the maps graphics layer
theMap.graphics.clear();
theMap.infoWindow.hide();
//QueryTask returns a featureSet. Loop through features in the featureSet and add them to the map.
//Performance enhancer - assign featureSet array to a single variable.
var resultFeatures = featureSet.features;
for (var i=0, il=resultFeatures.length; i<il; i++)
{
//Get the current feature from the featureSet. Feature is a graphic
var graphic = resultFeatures[i];
graphic.setSymbol(symbol);
//Set the infoTemplate.
graphic.setInfoTemplate(infoTemplate);
//Add graphic to the map graphics layer.
theMap.graphics.add(graphic);
}
//Zoom to the extent of the graphics
var myFeatureExtent = esri.graphicsExtent(resultFeatures);
theMap.setExtent(myFeatureExtent.getExtent().expand(3));
//Refresh the URL with the currently selected parcel
window.history.pushState(null,null,"?id=" + graphic.attributes.OBJECTID);
}
// END OF ESRI MAP CREATION
// STORE CREDENTIALS
function loadCredentials(){
var idJson, idObject;
if (supports_local_storage()) {
// read from local storage
idJson = window.localStorage.getItem(cred);
}
else {
// read from a cookie
idJson = cookie(cred);
}
if (idJson && idJson != "null" && idJson.length > 4) {
idObject = JSON.parse(idJson);
esriId.initialize(idObject);
}
else {
// console.log("didn't find anything to load :(");
}
}
function storeCredentials(){
// make sure there are some credentials to persist
if (esriId.credentials.length === 0) {
return;
}
// serialize the ID manager state to a string
var idString = JSON.stringify(esriId.toJson());
// store it client side
if (supports_local_storage()) {
// use local storage
window.localStorage.setItem(cred, idString);
// console.log("wrote to local storage");
}
else {
// use a cookie
cookie(cred, idString, {expires: 1});
// console.log("wrote a cookie :-/");
}
}
function supports_local_storage(){
try {
return "localStorage" in window && window["localStorage"] !== null;
} catch (e) {
return false;
}
}
// END OF CREDENTIALS
dojo.addOnLoad(init);
});
</script>
</head>
<!-- START OF PAGE LAYOUT -->
<body class="claro">
<div id="printButton"></div>
<!--<input type="button" id="printButton" value="Print" onclick="print()">-->
<div id="content" dojotype="dijit.layout.BorderContainer" design="headline" gutters="true" style="width: 800px; height: 800px; margin: 0;">
<div id="mapdiv" dojotype="dijit.layout.ContentPane" region="center" style="overflow:hidden;"></div>
</div>
</body>
<!-- END OF PAGE LAYOUT -->
</html>
... View more
08-06-2019
01:28 PM
|
0
|
4
|
4004
|
POST
|
I certainly appreciate that! In the example I have all the same required modules and functions in my script along with the parser.parse() and esriConfig.defaults.io.proxyUrl = "/proxy/"; is the only other thing that needs to be added the print dijit code below? // print dijit app.printer = new Print({ map: app.map, url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task" }, dom.byId("printButton")); app.printer.startup(); Is var app = {}; and the app. prefix for printer necessary?
... View more
08-06-2019
12:49 PM
|
0
|
6
|
4004
|
POST
|
Hi Ben, I have been reading through the API Reference page and example for the past week but for some reason, I have been unable to implement this. I am a novice when it comes to JS so I may not be fully understanding how to set this up.
... View more
08-06-2019
12:28 PM
|
0
|
8
|
4004
|
POST
|
I have a map that was created using "Selecting Features Using URL Parameters" where an ID is passed in the URL and the map creates a graphic of the selected feature, zooms to it and hides everything else in the layer (so I can only see the feature that the object ID matches the ID in the URL (along with the basemap and another feature layer). It is a ArcGIS API for JavaScript map built with 3.29 and the map is displayed in a dijit Border Container / Content Pane. Is there any way to take the final rendered map an convert it into an image to be used elsewhere, say in a PDF along with attributes from that selected feature? The layer that is getting queried is behind credentials so when the page first loads it asks for a log in and then the map renders as it should. I have tried the screenshot method using html2canvas, canvas.toBlob, Filesaver but the screenshot does not contain anything other than the tiled basemap. Any help would be greatly appreciated. Thank you.
... View more
08-06-2019
10:48 AM
|
0
|
10
|
5194
|
POST
|
Hi Kelly - I don't think updating the our code to 4.x will be in the picture due to a time constraint. Is there anything available for 3.x that could satisfy my need? I have been trying to work with PrintTask/PrintTemplate/etc but honestly, none of it is making sense and I can't seem to get it to work. I am using JS to create a new map (separate from the webmaps we already have created on AGO) that is bringing in rest services from our own server (one of which is under credentials) I have a screenshot button working but it only shows the basemap and no layers - even the layers with no credentials. All I really need is to take this map that I've created, turn it into an image/screenshot and place it into an HTML <div>.
... View more
08-05-2019
10:59 AM
|
1
|
0
|
813
|
POST
|
srikanth dasari venkata This screenshot function is exactly what I have been looking for but when I click the button, all that is in the screenshot is the basemap - do you happen to know if this functionality works with graphics layers, dynamic map service layers or a feature layer? Or can this even be done? My goal is to have a screenshot of the webmap I've created using the JS API
... View more
08-05-2019
10:47 AM
|
0
|
0
|
367
|
POST
|
Hi Kelly, Is there any way to do this onload versus having the user physically draw out the area? I have already created a map in the 3.29 version of the API that does everything I need it to - has a set container size, zooms in to the feature based on the ID in the URL, highlights the feature and hides the rest of the features in that layer. I spoke with someone yesterday and they mentioned that MapView in version 4.12 of the API may work but it's been very tricky updating the code from 3.29 to 4.12 and have it perform the same way. I have a file that uses FPDF to generate a PDF and the goal is to take what appears in the HTML <div> (on the page with the Javascript) and place it in the PDF.
... View more
08-02-2019
08:57 AM
|
0
|
2
|
813
|
POST
|
I have been working at this for a week no with no luck and I am not sure if I am going about this the correct way. I have gone through the examples that Tanu has posted about https://www.esri.com/arcgis-blog/products/arcgis-enterprise/uncategorized/printing-popups-from-web-application/Printing Popups from Web Application, etc but nothing seems to work. I don't want to create another web application just to print this information so what we are looking for is to have a hyperlink in the features popup (shown below) that opens a new page with the objectid in the URL. I'd like to automatically generate a PDF with clicking on "Generate Map" that displays the feature that has a matching objectid to what is in the URL along with some additional layers and a few important attributes below the map. Right now I have a php file that opens up an HTML page that displays a map with the feature layers along with the attributes that queries the objectid in the URL but I cannot get the map to display only that feature. Another route I have taken is to publish a printing service that has a template I created but I am unable to pass any of the attributes to the layout. Does anyone have any tips or information on how to do this? I am a novice when it comes to JavaScript, ArcPy, etc .
... View more
07-24-2019
01:14 PM
|
0
|
4
|
978
|
POST
|
Unfortunately we have to go through someone here on campus in order to reach out to tech support so I am hoping it won't take too long as now all of our services are down on this machine. That is a possibility. I just restarted the machine and it seems to be running a bit better but still timing out.
... View more
02-20-2019
11:58 AM
|
0
|
0
|
6565
|
POST
|
There are 4 log files under C:\arcgisdatastore\logs\machine_name\server but only 3 have messages <Msg time="2019-02-19T09:43:21,798" type="WARNING" code="110130" source="Data Store" process="3596" thread="1" methodName="" machine=" " user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-19T09:43:57,762" type="WARNING" code="110130" source="Data Store" process="3596" thread="1" methodName="" machine=" " user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-19T09:44:33,713" type="WARNING" code="110130" source="Data Store" process="3596" thread="1" methodName="" machine=" " user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-19T09:44:33,713" type="SEVERE" code="110131" source="Data Store" process="3596" thread="1" methodName="" machine=" " user="" elapsed="">ArcGIS Data Store encountered too many problems. Failover may be invoked if standby is configured.</Msg> <Msg time="2019-02-19T09:44:33,718" type="SEVERE" code="110653" source="Data Store" process="3596" thread="1" methodName="" machine=" " user="" elapsed="">Data store machine '**' has failed.</Msg> <Msg time="2019-02-19T09:51:45,72" type="WARNING" code="110129" source="Data Store" process="3596" thread="1" methodName="" machine=" " user="" elapsed="">Attempt to start ArcGIS Data Store service failed. Cannot run program "C:\Program Files\ArcGIS\DataStore\bin\pkill.exe": CreateProcess error=19, The media is write protected</Msg> <Msg time="2019-02-19T10:17:13,980" type="WARNING" code="110130" source="Data Store" process="2824" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-19T10:17:49,987" type="WARNING" code="110130" source="Data Store" process="2824" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-02T00:00:48,156" type="WARNING" code="110718" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">Error during relational data store vacuum/analyze maintenance on ' '. Failed to execute a SQL script.</Msg> <Msg time="2019-02-14T00:01:34,443" type="WARNING" code="110130" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-15T09:13:35,595" type="WARNING" code="110130" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-15T09:14:44,168" type="WARNING" code="110130" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-18T13:43:35,191" type="WARNING" code="110130" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-18T13:48:34,188" type="WARNING" code="110130" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-18T13:49:35,673" type="WARNING" code="110130" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-18T15:34:36,659" type="WARNING" code="110130" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-18T15:35:13,941" type="WARNING" code="110130" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-18T15:52:35,720" type="WARNING" code="110130" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-18T15:53:13,237" type="WARNING" code="110130" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-18T15:53:50,126" type="WARNING" code="110130" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store has detected an issue with db.</Msg> <Msg time="2019-02-18T15:53:50,128" type="SEVERE" code="110131" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">ArcGIS Data Store encountered too many problems. Failover may be invoked if standby is configured.</Msg> <Msg time="2019-02-18T15:53:50,135" type="SEVERE" code="110653" source="Data Store" process="3164" thread="1" methodName="" machine="**" user="" elapsed="">Data store machine '**' has failed.</Msg>
... View more
02-20-2019
08:12 AM
|
0
|
2
|
6565
|
POST
|
Any help would be appreciated... we have a few hosted map services that sit on a local ArcGIS Server. Starting around the 14th of this month, a few of the services started to experience some issues and not load correctly in the web maps/web mapping applications and operations dashboard. Nothing has changed in the settings, etc so I am curious why this has started to occur. In the server logs I keep received error messages like: Error performing query operation Error handling service request :Processing request took longer than the usage timeout for service '**'. Processing request took longer than the usage timeout for service '**'. Server request timed out. Check that the usage timeout is appropriately configured for such requests. Error performing query operation Error handling service request :java.lang.OutOfMemoryError: Java heap space Instance of service '**' failed to process a request. ArcGIS Data Store has detected an issue with db. We have increased the heap sizes which has corrected the java heap space error message but that is about the only thing that has been solved. What's bizarre though, is that we have another service that has editing enabled and sits in the same location as the other services but is working just fine (though it does not have as many records as the problem services) Thank you for your time!
... View more
02-20-2019
07:23 AM
|
1
|
4
|
9494
|
POST
|
Hi Andrew, sorry for the delay - we ended up not finding a solution at that time and the folks who wanted to use Survey123 decided it wasn't what they needed so we never pursued a fix.
... View more
08-07-2018
10:37 AM
|
0
|
0
|
1169
|
Title | Kudos | Posted |
---|---|---|
1 | 07-29-2020 10:51 AM | |
1 | 12-30-2019 07:39 AM | |
1 | 08-05-2019 10:59 AM | |
1 | 02-20-2019 07:23 AM | |
1 | 12-16-2019 05:11 AM |
Online Status |
Offline
|
Date Last Visited |
11-25-2020
09:12 AM
|