ArcGIS For Server10.1新特性之-服务器端打印服务及前端调用

本文主要是介绍ArcGIS For Server10.1新特性之-服务器端打印服务及前端调用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

ArcGIS For Server10.1新特性之一就是服务器端打印,这个打印功能使用起来非常的方便,因为它是一个现成的GP服务,使用的时候只要输入相应的地图,地图范围,模板的名称等,就可以按需打印出你需要的地图。下面我们来看一下从制作模版到发布服务及服务调用的整个流程吧:

1、自己定义一个打印模板,如下图是布局视图:

   将模版保存到C:\Program Files (x86)\ArcGIS\Desktop10.1\Templates\ExportWebMapTemplates(当然你也可以保存到其他路径下,在发布服务的时候你可以指定你自己的路径)

2、在ArcToolBox中打开Export Web Map工具:

输入参数:Web Map as JSON为空;Output File为默认参数;Format可以自己输入;Layout Templates Folder(optional)选择一个模板文件夹(这里选择ArcGIS安装目录的模板文件夹),然后Layout  Templates (optional)就可以选择一个默认的模板了

点击OK,打开菜单栏Geoprocessing/Results,执行完成后选中Export Web Map右键Share as Geoprocessing services

下一步、下一步:Analyse后如果没有错误,直接点击Publish发布:

ArcCatalog中查看如下:

3、服务发布好后,可一下在Flex中如何调用一把:ArcGIS Flex API3.0也增加了对该打印服务的支持:

代码如下:print.mxml

复制代码
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:esri="http://www.esri.com/2008/ags"xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"><fx:Declarations><!-- 将非可视元素(例如服务、值对象)放在此处 --></fx:Declarations><fx:Script><![CDATA[import mx.managers.PopUpManager;  private function onclick(event:MouseEvent):void{var popWin:printForm = printForm(PopUpManager.createPopUp(this,printForm,false)); popWin.printTask.getServiceInfo();//调用 打印 GP,获取模版和格式参数
                popWin.map = this.myMap;}]]></fx:Script><esri:Map id="myMap">         <esri:ArcGISDynamicMapServiceLayer url="http://localhost:6080/arcgis/rest/services/routTest2/MapServer"/></esri:Map><mx:Button id="button" x="409" y="10" label="打印" click="onclick(event)"/>
</s:Application>
复制代码

printForm.mxml

复制代码
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:s="library://ns.adobe.com/flex/spark"xmlns:mx="library://ns.adobe.com/flex/mx"xmlns:esri="http://www.esri.com/2008/ags"width="100%" height="100%"close="PopUpManager.removePopUp(this)"><fx:Script><![CDATA[import com.esri.ags.Map;import com.esri.ags.events.PrintEvent;import com.esri.ags.tasks.supportClasses.DataFile;import com.esri.ags.tasks.supportClasses.JobInfo;import com.esri.ags.tasks.supportClasses.ParameterValue;import com.esri.ags.tasks.supportClasses.PrintServiceInfo;import com.esri.ags.tasks.supportClasses.LegendOptions;import com.esri.ags.tasks.supportClasses.LegendLayer;import mx.collections.IList;import mx.controls.Alert;import mx.managers.PopUpManager;import mx.rpc.events.FaultEvent;import com.esri.ags.layers.*;[Bindable]          public  var  map:Map;//打印结束后处理 private function printTask_executeCompleteHandler(event:PrintEvent):void{var paramValue:ParameterValue = event.executeResult.results[0];var dataFile:DataFile = paramValue.value as DataFile;navigateToURL(new URLRequest(dataFile.url));}private function printTask_getResultDataCompleteHandler(event:PrintEvent):void{var dataFile:DataFile = event.parameterValue.value as DataFile;navigateToURL(new URLRequest(dataFile.url));}private function printTask_jobCompleteHandler(event:PrintEvent):void{var jobInfo:JobInfo = event.jobInfo;if (jobInfo.jobStatus == JobInfo.STATUS_SUCCEEDED){printTask.getResultData(jobInfo.jobId);}else{Alert.show(jobInfo.jobStatus);}}//获取打印参数(模版和格式)protected function printTask_getServiceInfoCompleteHandler(event:PrintEvent):void{                initLayoutTemplates(event.serviceInfo);initFormats(event.serviceInfo);printButton.enabled = true;}//获得所有支持的打印格式private function initFormats(serviceInfo:PrintServiceInfo):void{var formatsVisibility:Boolean = true;var formats:IList = serviceInfo.formats;formatsDDL.selectedItem = serviceInfo.defaultFormat;}//获得所有模版private function initLayoutTemplates(serviceInfo:PrintServiceInfo):void{var layoutTemplatesVisibility:Boolean = true;                                layoutTemplatesFI.label = "模版";        var layoutTemplates:IList = serviceInfo.layoutTemplates;                layoutTemplatesDDL.selectedItem = serviceInfo.defaultLayoutTemplate;}//获取打印比例尺private function printButton_exportWebMapClickHandler(event:MouseEvent):void{layoutOptions.title = txtTitle.text;layoutOptions.legendOptions = getLegendOptions();var oldscale:Number;var oldLODs:Array;if (scaleCheckbox.selected){oldscale =map.scale;oldLODs = map.lods;map.lods = null; //prevent LOD snapping
                    map.scale = Number(scaleInput.text);}if (printTask.getServiceInfoLastResult.isServiceAsynchronous){printTask.submitJob(printParameters);}else{printTask.execute(printParameters);}if (scaleCheckbox.selected){map.scale = oldscale;map.lods = oldLODs;}}private function getLegendOptions():LegendOptions{var result:LegendOptions = new LegendOptions();var legendLayers:Array = [];for each (var layer:Layer in map.layers){if (layer.name.indexOf("hiddenLayer_") == -1 && !(layer is GraphicsLayer && !(layer is FeatureLayer))){                        var legendLayer:LegendLayer = new LegendLayer();legendLayer.layerId = layer.id;legendLayers.push(legendLayer);                        }}result.legendLayers = legendLayers;return result;}protected function printTask_faultHandler(event:FaultEvent):void{Alert.show(event.fault.toString());}]]></fx:Script><fx:Declarations><esri:PrintTask id="printTask" url="http://localhost:6080/arcgis/rest/services/ExportWebMap/GPServer/Export%20Web%20Map"    executeComplete="printTask_executeCompleteHandler(event)"fault="printTask_faultHandler(event)"getResultDataComplete="printTask_getResultDataCompleteHandler(event)"getServiceInfoComplete="printTask_getServiceInfoCompleteHandler(event)"jobComplete="printTask_jobCompleteHandler(event)"showBusyCursor="true"/><esri:PrintParameters id="printParameters"format="{formatsDDL.selectedItem}"layoutTemplate="{layoutTemplatesDDL.selectedItem}"map="{map}"preserveScale="{scaleCheckbox.selected}"><esri:layoutOptions><esri:LayoutOptions id="layoutOptions"/></esri:layoutOptions></esri:PrintParameters></fx:Declarations><mx:FormItem id="titleFI"  width="100%" label="标题" >                <s:TextInput id="txtTitle"  width="100%"  text="请输入标题"/>                </mx:FormItem><mx:FormItem id="layoutTemplatesFI"  includeInLayout="true" width="100%" label="模版"  visible="true">                <s:DropDownList id="layoutTemplatesDDL" width="175"     dataProvider="{printTask.getServiceInfoLastResult.layoutTemplates}"requireSelection="true"/>                            </mx:FormItem><mx:FormItem id="formatsFI"  width="100%" label="格式"  visible="true">            <s:DropDownList id="formatsDDL"   dataProvider="{printTask.getServiceInfoLastResult.formats}"    width="100" requireSelection="true"/>                    </mx:FormItem><s:HGroup id="scaleFI"width="100%"horizontalAlign="center"visible="true"><s:CheckBox id="scaleCheckbox" label="打印比例尺"/><s:TextInput id="scaleInput"width="100%"  enabled="{scaleCheckbox.selected}"restrict="0-9"/></s:HGroup><s:HGroup width="100%" horizontalAlign="center" ><s:Button id="printButton" label="打印"      click="printButton_exportWebMapClickHandler(event)"         enabled="false"/></s:HGroup>
</mx:TitleWindow>
复制代码
文章出处:http://www.cnblogs.com/esrichina/archive/2012/12/13/2816501.html

这篇关于ArcGIS For Server10.1新特性之-服务器端打印服务及前端调用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/636113

相关文章

从入门到精通C++11 <chrono> 库特性

《从入门到精通C++11<chrono>库特性》chrono库是C++11中一个非常强大和实用的库,它为时间处理提供了丰富的功能和类型安全的接口,通过本文的介绍,我们了解了chrono库的基本概念... 目录一、引言1.1 为什么需要<chrono>库1.2<chrono>库的基本概念二、时间段(Durat

Java中调用数据库存储过程的示例代码

《Java中调用数据库存储过程的示例代码》本文介绍Java通过JDBC调用数据库存储过程的方法,涵盖参数类型、执行步骤及数据库差异,需注意异常处理与资源管理,以优化性能并实现复杂业务逻辑,感兴趣的朋友... 目录一、存储过程概述二、Java调用存储过程的基本javascript步骤三、Java调用存储过程示

Python中Tensorflow无法调用GPU问题的解决方法

《Python中Tensorflow无法调用GPU问题的解决方法》文章详解如何解决TensorFlow在Windows无法识别GPU的问题,需降级至2.10版本,安装匹配CUDA11.2和cuDNN... 当用以下代码查看GPU数量时,gpuspython返回的是一个空列表,说明tensorflow没有找到

python如何调用java的jar包

《python如何调用java的jar包》这篇文章主要为大家详细介绍了python如何调用java的jar包,文中的示例代码简洁易懂,具有一定的借鉴价值,有需要的小伙伴可以参考一下... 目录一、安装包二、使用步骤三、代码演示四、自己写一个jar包五、打包步骤六、方法补充一、安装包pip3 install

前端如何通过nginx访问本地端口

《前端如何通过nginx访问本地端口》:本文主要介绍前端如何通过nginx访问本地端口的问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、nginx安装1、下载(1)下载地址(2)系统选择(3)版本选择2、安装部署(1)解压(2)配置文件修改(3)启动(4)

HTML中meta标签的常见使用案例(示例详解)

《HTML中meta标签的常见使用案例(示例详解)》HTMLmeta标签用于提供文档元数据,涵盖字符编码、SEO优化、社交媒体集成、移动设备适配、浏览器控制及安全隐私设置,优化页面显示与搜索引擎索引... 目录html中meta标签的常见使用案例一、基础功能二、搜索引擎优化(seo)三、社交媒体集成四、移动

HTML input 标签示例详解

《HTMLinput标签示例详解》input标签主要用于接收用户的输入,随type属性值的不同,变换其具体功能,本文通过实例图文并茂的形式给大家介绍HTMLinput标签,感兴趣的朋友一... 目录通用属性输入框单行文本输入框 text密码输入框 password数字输入框 number电子邮件输入编程框

HTML img标签和超链接标签详细介绍

《HTMLimg标签和超链接标签详细介绍》:本文主要介绍了HTML中img标签的使用,包括src属性(指定图片路径)、相对/绝对路径区别、alt替代文本、title提示、宽高控制及边框设置等,详细内容请阅读本文,希望能对你有所帮助... 目录img 标签src 属性alt 属性title 属性width/h

CSS3打造的现代交互式登录界面详细实现过程

《CSS3打造的现代交互式登录界面详细实现过程》本文介绍CSS3和jQuery在登录界面设计中的应用,涵盖动画、选择器、自定义字体及盒模型技术,提升界面美观与交互性,同时优化性能和可访问性,感兴趣的朋... 目录1. css3用户登录界面设计概述1.1 用户界面设计的重要性1.2 CSS3的新特性与优势1.

HTML5 中的<button>标签用法和特征

《HTML5中的<button>标签用法和特征》在HTML5中,button标签用于定义一个可点击的按钮,它是创建交互式网页的重要元素之一,本文将深入解析HTML5中的button标签,详细介绍其属... 目录引言<button> 标签的基本用法<button> 标签的属性typevaluedisabled