Я использую ArcGIS javaScript 3.5, и я хочу реализовать карту печати. Я знаю, что это встроенный инструмент, который мы также можем использовать, но моя проблема в том, чтобы реализовать все три шага (Печать, Печать, PrintOut) одним щелчком мыши (Предпочитаю другой щелчок).
для этого я сделал что-то вроде ---
сначала я добавил один div на уровне дизайна и установил видимость как false
<div id="print_button" style="visibility:hidden;display:none;"></div>
В инициализации я использую опцию esri.dijit.Print
var app = {};
app.webmapId = "8315cf7d20f0484e869c4791f70f4f15";
app.printUrl = "abc/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";
var layouts = [{
"name": "Letter ANSI A Landscape",
"label": "Landscape (PDF)",
"format": "pdf",
"options": {
"legendLayers": [], // empty array means no legend
"scalebarUnit": "Miles",
"titleText": "Map"
}
}];
var templates = [];
dojo.forEach(layouts, function (lo) {
var t = new esri.tasks.PrintTemplate();
t.layout = lo.name;
t.label = lo.label;
t.format = lo.format;
t.layoutOptions = lo.options
templates.push(t);
});
app.printer = new esri.dijit.Print({
"map": map,
"templates": templates,
url: app.printUrl,
}, dojo.byId("print_button"));
app.printer.startup();
и в моем щелчке внутри я хочу нажать эту кнопку печати
function export1() {
document.getElementById('print_button').click();//This is not working obviously this is not a button
return false;
}
Как я могу этого добиться. Помогите, пожалуйста.
После анализа этого div я нашел эти элементы
<div class="esriPrint">
<span class="dijit dijitReset dijitInline dijitButton esriPrintButton dijitButtonDisabled dijitDisabled"
role="presentation" widgetId="dijit_form_Button_0">
<span class="dijitReset dijitInline dijitButtonNode" role="presentation" data-dojo-attach-event="ondijitclick:_onClick">
<span disabled="" class="dijitReset dijitStretch dijitButtonContents" id="dijit_form_Button_0" role="button" aria-disabled="true"
aria-labelledby="dijit_form_Button_0_label" style="-ms-user-select: none;" data-dojo-attach-point="titleNode,focusNode">
<span class="dijitReset dijitInline dijitIcon dijitNoIcon" data-dojo-attach-point="iconNode">
</span>
<span class="dijitReset dijitToggleButtonIconChar">
●
</span>
<span class="dijitReset dijitInline dijitButtonText" id="dijit_form_Button_0_label" data-dojo-attach-point="containerNode">
Printing
</span>
</span>
</span>
<input tabindex="-1" disabled="" class="dijitOffScreen" role="presentation" type="button" value="" data-dojo-attach-point="valueNode">
</span></div>
<div class="esriPrint">
<span class="dijit dijitReset dijitInline dijitButton esriPrintButton" role="presentation" widgetId="dijit_form_Button_1">
<span class="dijitReset dijitInline dijitButtonNode" role="presentation" data-dojo-attach-event="ondijitclick:_onClick">
<span tabindex="0" class="dijitReset dijitStretch dijitButtonContents" id="dijit_form_Button_1"
role="button" aria-labelledby="dijit_form_Button_1_label" style="-ms-user-select: none;" data-dojo-attach-point="titleNode,focusNode">
<span class="dijitReset dijitInline dijitIcon dijitNoIcon" data-dojo-attach-point="iconNode">
</span>
<span class="dijitReset dijitToggleButtonIconChar">
●
</span>
<span class="dijitReset dijitInline dijitButtonText" id="dijit_form_Button_1_label" data-dojo-attach-point="containerNode">
Print
</span>
</span>
</span>
<input tabindex="-1" class="dijitOffScreen" role="presentation" type="button" value="" data-dojo-attach-point="valueNode">
</span></div>
но как я могу вызвать это событие щелчка, потому что элемент легко найти, но не просто вызвать событие щелчка, или я не знаю, как вызвать это событие data-dojo-attach-event = "ondijitclick: _onClick"?
Вы можете подсказать, как назвать это событие?