描述

  1. OSP提供的打印服务,可以将地图页面输出到打印设备。 本示例介绍:点击“打印地图”,会弹出地图打印窗口。

代码 (文件格式为 UTF-8)


<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	   <title>SuperMap Online Service Platform Sample - 地图打印</title>
	<script type="text/javascript" src="http://services.supermapcloud.com/iserver/api?key=aXtbCHyF5FSZn6TeeEywSW0u8TDHrwC0IjFudD2j5xM%3D&v=1.1"></script>
    <script type="text/javascript">
        var map = null;
		var layer = null;
        function onPageLoad() {
           layer = new SuperMap.Layer.CloudLayer();
			 map = new SuperMap.Map("mapDiv", { controls: [
                      new SuperMap.Control.PanZoomBar(),
                      new SuperMap.Control.Navigation({
                          dragPanOptions: {
                              enableKinetic: true
                          }
                      })], allOverlays: true
            });
			map.addLayer(layer);
			map.setCenter(new SuperMap.LonLat(12958399.4681885, 4852082.44060595),11);
        }

        //地图打印
        function printMap() {
            var printService = new SuperMap.OSP.Service.PrintService();
            printService.printMap();
        } 
    </script>

</head>
<body onload="onPageLoad()">
    <div id="mapDiv" style="position: absolute;  height:398px;width:498px; top: 0px;
        left: 0px; border: solid 1px">
    </div>
    <div id="operatePanel" style="position: absolute; width: 200px; left:500; top:0px;
        font-size: 12px; border: solid 0px #969696; z-index: 100; padding-bottom: 5px;
        background-image: url(../../images/toolbar_backgroundb.png);">
        <font style="font-family: Verdana,Arial,Helvetica,sans-serif; font-size: 100%">地图打印:</font>
        <p>
            OSP提供的打印服务,可以将地图页面输出到打印设备。。</p>
        <input type="button" value="打印地图" style="background-color: #CCCCCC; border: double;"
            onclick="printMap()" />
    </div>
    <div id="divInfo" style="clear: both">
    </div>
</body>
</html>