700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > ArcGIS API for JavaScript 3.x 地图打印

ArcGIS API for JavaScript 3.x 地图打印

时间:2018-06-22 21:35:42

相关推荐

ArcGIS API for JavaScript 3.x 地图打印

地图打印分为两种,按需使用:

1.使用arcgis server服务进行地图打印

2.使用浏览器进行当前屏幕截图

以下内容为server服务地图打印,浏览器打印详情查看/console/editor/html/108817017

<html xmlns="/1999/xhtml"><head runat="server"><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>地图打印</title><link rel="stylesheet" href="http://location/arcgis_js_api/library/3.15/3.15/dijit/themes/claro/claro.css" /><link rel="stylesheet" href="http://location/arcgis_js_api/library/3.15/3.15compact/esri/css/esri.css"><script src="/libs/jquery/2.1.1/jquery.min.js" type="text/javascript"></script><script src="http://location/arcgis_js_api/library/3.15/3.15/init.js" type="text/javascript"></script></head><body><div id="map" style="width:100%;height:100%;"><button id="btn" title="打印">打印</button></div></body></html><script>var map;require(["esri/map","esri/tasks/PrintTask", "esri/tasks/PrintTemplate","esri/tasks/PrintParameters"], function(Map,PrintTask, PrintTemplate,PrintParameters) {var startExtent = new esri.geometry.Extent(114.309, 30.578, 115, 37,new esri.SpatialReference({ wkid:4326}) );map = new Map("map", {extent:startExtent,center: [114.309, 30.578], //地图加载后,初始位置zoom: 12, //放大级别,值越大放大的比例就越大slider: false,maxZoom: 16, //地图最大缩放级别minZoom: 7, //地图最小缩放级别logo: false //不显示Esri的logo});//加载地图服务var myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("/arcgis/rest/services/ChinaOnlineStreetWarm/MapServer");map.addLayer(myTiledMapServiceLayer); //添加到地图中$("#btn").on("click",function(evt){print();})var printTask = new PrintTask("http://location/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"); var template = new PrintTemplate();function print(){template.exportOptions = { width: 800, height: 600, dpi: 96 }; var layouts = {options: {titleText: "测试"}};template.layoutOptions= layouts.options;template.format = "PDF"; template.layout = "A3 Portrait"; template.preserveScale = false; var params = new PrintParameters(); params.map = map; params.template = template; printTask.execute(params, function(evt){ console.log(evt);window.open(evt.url); //在新的标签页打开打印连接});}});</script>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。