![](/img/trans.png)
[英]finding is point laying on line or not in esri map using arcgis API
[英]Esri ArcGIS Print the map
我正在使用ArcGIS javaScript 3.5,並且想實現打印地圖。我知道它是一個內置工具,我們也可以使用該服務,但是我的問題是一鍵實現所有三個步驟(打印,打印,打印輸出) (建議其他一些點擊)。
為此,我做了類似的事情-
首先,我在設計級別添加了一個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 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>
但是如何調用此click事件,因為它很容易找到元素,但調用click事件並不簡單,或者我不知道如何調用data-dojo-attach-event =“ ondijitclick:_onClick”此事件?
您能建議我如何調用此事件嗎?
雖然這不是一個完整的答案,但我認為您的.click()
失敗的原因是因為您“點擊”了錯誤的內容。 在地圖的源代碼中,我所擁有的只是:
<div id="printButton"></div>
但是在運行時,Dojo將其擴展為:
<div id="printButton">
<div class="esriPrint">
<span class="dijit dijitReset dijitInline esriPrintButton dijitButton" role="presentation" widgetid="dijit_form_Button_0">
<span class="dijitReset dijitInline dijitButtonNode" data-dojo-attach-event="ondijitclick:_onClick" role="presentation">
...etc
並注意第二個<span>
標記上的data-dojo-attach-event
標記。 我將看一下定位該<span>
標記,並查看是否可以在其上引發click事件。
是的.click()
正確的元素確實可以執行打印任務,我剛剛在自己的應用程序中嘗試過。 使用jQuery廣泛,所以就用選擇器#printButton .dijitInline
找到與類中的任何元件.dijitInline
這是的子<div id="printButton">
$('#printButton .dijitInline').click();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.