others_printscreen.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  8. <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7,IE=9,IE=10,IE=11"/>
  9. <title data-i18n="resources.title_printscreen"></title>
  10. <style type="text/css">
  11. .editPane {
  12. position: absolute;
  13. right: 180px;
  14. top: 10px;
  15. text-align: center;
  16. background: #FFF;
  17. z-index: 1000;
  18. }
  19. </style>
  20. </head>
  21. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  22. <div class='panel panel-primary editPane' id='editPane' style="z-index: 99999">
  23. <div class='panel-heading'>
  24. <h5 class='panel-title text-center' data-i18n="resources.text_printscreen"></h5>
  25. </div>
  26. <div class='panel-body' id='params'>
  27. <p></p>
  28. <div align='right' class='button-group'>
  29. <input type='button' id='btn1' class='btn btn-primary' data-i18n="[value]resources.btn_marker" onclick="createMarker()"/>
  30. <input type='button' id='btn2' class='btn btn-primary' data-i18n="[value]resources.btn_printscreen" onclick="mapToImg1()"/>
  31. <input type='button' id='btn3' class='btn btn-primary' data-i18n="[value]resources.text_input_value_clear" onclick="clearAllFeatures()"/>
  32. </div>
  33. </div>
  34. </div>
  35. <div id="map" style="position: relative;height: 100%;"></div>
  36. <script type="text/javascript" include="bootstrap" src="../js/include-web.js"></script>
  37. <script type="text/javascript" exclude="iclient-classic" include="MapToImg" src="../../dist/classic/include-classic.js"></script>
  38. <script type="text/javascript">
  39. var map, layer, markerLayer;
  40. var host = window.isLocal ? window.server : "https://iserver.supermap.io",
  41. smCompanyArr = [
  42. ["北京超图软件股份有限公司上海分公司", 13522414.5106, 3662690.3875, "上海市闸北虬江路1000号聚源大厦办公楼1505室"],
  43. ["北京超图软件股份有限公司广州分公司", 12608758.6677, 2647887.5456, "广州市体育西路109号高盛大厦9楼G单元"],
  44. ["北京超图软件股份有限公司成都分公司", 11584664.2393, 3588559.6862, "成都市高新区天府大道中段1268号天府软件园E区"],
  45. ["北京超图软件股份有限公司杭州分公司", 13375617.5430, 3538667.9064, "杭州市天目山路159号现代国际大厦A座"],
  46. ["北京超图软件股份有限公司西安分公司", 12127616.0783, 4064501.0071, "西安高新区丈八一路一号 汇鑫IBC(A座)"],
  47. ["北京超图软件股份有限公司长沙分公司", 12573006.2587, 3277897.5105, "长沙市芙蓉中路二段359号佳天国际新城北栋8H"],
  48. ["北京超图软件股份有限公司沈阳分公司", 13740261.8165, 5131821.5120, "沈阳市沈河区市府大路262甲号新华科技大厦"]
  49. ],
  50. url = host + "/iserver/services/map-china400/rest/maps/China";
  51. //定义layer图层,TiledDynamicRESTLayer:分块动态 REST 图层
  52. layer = new SuperMap.Layer.TiledDynamicRESTLayer("China", url, {
  53. transparent: true,
  54. cacheEnabled: true
  55. }, {maxResolution: "auto", useCanvas: false, useCORS: true});
  56. //为图层初始化完毕添加addLayer()事件
  57. layer.events.on({"layerInitialized": addLayer});
  58. map = new SuperMap.Map("map", {
  59. controls: [
  60. new SuperMap.Control.LayerSwitcher(),
  61. new SuperMap.Control.OverviewMap(),
  62. new SuperMap.Control.ScaleLine(),
  63. new SuperMap.Control.Zoom(),
  64. new SuperMap.Control.Navigation({
  65. dragPanOptions: {
  66. enableKinetic: true
  67. }
  68. })
  69. ]
  70. });
  71. markerLayer = new SuperMap.Layer.Markers("Markers");
  72. function addLayer() {
  73. map.addLayers([layer, markerLayer]);
  74. map.setCenter(new SuperMap.LonLat(9733502.481499, 4614406.969325), 4);
  75. }
  76. //移除整个图层要素
  77. function clearAllFeatures() {
  78. markerLayer.clearMarkers();
  79. if (map.popups.length != 0) {
  80. var i = 0, lengthPopup = map.popups.length;
  81. while (i < lengthPopup) {
  82. map.removePopup(map.popups[0]);
  83. i++;
  84. }
  85. }
  86. }
  87. //添加标注
  88. function createMarker() {
  89. markerLayer.clearMarkers();
  90. for (var i = 0, lengthCompany = smCompanyArr.length; i < lengthCompany; i++) {
  91. var point = new SuperMap.Geometry.Point(parseFloat(smCompanyArr[i][1]), parseFloat(smCompanyArr[i][2])),
  92. strContent = new Array(smCompanyArr[i][0], smCompanyArr[i][3]),
  93. size = new SuperMap.Size(32, 32),
  94. offset = new SuperMap.Pixel(-(size.w / 2), -size.h),
  95. feature = new SuperMap.Feature(markerLayer, new SuperMap.LonLat(point.x, point.y));
  96. feature.data.icon = new SuperMap.Icon("images/markerflag.png", size, offset);
  97. var marker = feature.createMarker();
  98. var markerClick = function (evt, feature, strContent) {
  99. SuperMap.Event.stop(evt);
  100. this.win.open(feature, {
  101. "name": strContent[0],
  102. "informition": strContent[1]
  103. });
  104. };
  105. marker.events.register("click", feature, function (feature, strContent) {
  106. return function (evt) {
  107. markerClick(evt, feature, strContent);
  108. }
  109. }(feature, strContent));
  110. markerLayer.addMarker(marker);
  111. }
  112. }
  113. this.win = new InforWindow_z({"map": map});
  114. function InforWindow_z(param) {
  115. var t = this;
  116. t.infowin = null;
  117. t.map = null;
  118. t.init = function (param) {
  119. for (var key in param) {
  120. t[key] = param[key];
  121. }
  122. }
  123. t.open = function (feature, data) {
  124. t.close();
  125. t.create(feature, data);
  126. }
  127. t.create = function (feature, data) {
  128. var contentHTML = "<div style='font-size:.8em; opacity: 0.8; overflow-y:hidden;'>" +
  129. "<span style='font-weight: bold; font-size: 18px;'>"+resources.text_detailedInfo+"</span><br>";
  130. contentHTML += resources.text_companyName + data.name + "<br>";
  131. contentHTML += resources.text_companyAddress + data.informition + "</div>";
  132. //初始化一个弹出窗口,当某个地图要素被选中时会弹出此窗口,用来显示选中地图要素的属性信息
  133. var popup = new SuperMap.Popup.FramedCloud("chicken",
  134. feature.marker.lonlat,
  135. null,
  136. contentHTML,
  137. null,
  138. true);
  139. feature.popup = popup;
  140. map.addPopup(popup);
  141. t.infowin = popup;
  142. }
  143. t.close = function () {
  144. if (t.infowin) {
  145. try {
  146. t.infowin.hide();
  147. t.infowin.destroy();
  148. }
  149. catch (e) {
  150. }
  151. }
  152. }
  153. t.init(param);
  154. }
  155. function mapToImg1() {
  156. MapToImg && MapToImg.excute(map);
  157. }
  158. </script>
  159. </body>
  160. </html>