03_themeUnique.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="UTF-8">
  8. <title data-i18n="resources.title_themeUnique"></title>
  9. <script type="text/javascript" src="../js/include-web.js"></script>
  10. </head>
  11. <body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
  12. <div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
  13. <script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
  14. <script type="text/javascript">
  15. var host = window.isLocal ? window.server : "https://iserver.supermap.io";
  16. var map, themeService, themeUnique, themeParameters, themeLayer,
  17. url = host + "/iserver/services/map-china400/rest/maps/China";
  18. map = L.map('map', {
  19. center: [30, 84],
  20. maxZoom: 18,
  21. zoom: 3
  22. });
  23. L.supermap.tiledMapLayer(url, {noWrap: true, transparent: true}).addTo(map);
  24. createTheme();
  25. function createTheme() {
  26. themeService = L.supermap.themeService(url);
  27. var style1, style2, style3, style4, style5, style6;
  28. style1 = new SuperMap.ServerStyle({
  29. fillForeColor: new SuperMap.ServerColor(248, 203, 249),
  30. lineColor: new SuperMap.ServerColor(255, 255, 255),
  31. lineWidth: 0.1
  32. });
  33. style2 = new SuperMap.ServerStyle({
  34. fillForeColor: new SuperMap.ServerColor(196, 255, 189),
  35. lineColor: new SuperMap.ServerColor(255, 255, 255),
  36. lineWidth: 0.1
  37. });
  38. style3 = new SuperMap.ServerStyle({
  39. fillForeColor: new SuperMap.ServerColor(255, 173, 173),
  40. lineColor: new SuperMap.ServerColor(255, 255, 255),
  41. lineWidth: 0.1
  42. });
  43. style4 = new SuperMap.ServerStyle({
  44. fillForeColor: new SuperMap.ServerColor(255, 239, 168),
  45. lineColor: new SuperMap.ServerColor(255, 255, 255),
  46. lineWidth: 0.1
  47. });
  48. style5 = new SuperMap.ServerStyle({
  49. fillForeColor: new SuperMap.ServerColor(173, 209, 255),
  50. lineColor: new SuperMap.ServerColor(255, 255, 255),
  51. lineWidth: 0.1
  52. });
  53. style6 = new SuperMap.ServerStyle({
  54. fillForeColor: new SuperMap.ServerColor(132, 164, 232),
  55. lineColor: new SuperMap.ServerColor(255, 255, 255),
  56. lineWidth: 0.1
  57. });
  58. var themeUniqueIteme1 = new SuperMap.ThemeUniqueItem({
  59. unique: "黑龙江省",
  60. style: style1
  61. }),
  62. themeUniqueIteme2 = new SuperMap.ThemeUniqueItem({
  63. unique: "湖北省",
  64. style: style2
  65. }),
  66. themeUniqueIteme3 = new SuperMap.ThemeUniqueItem({
  67. unique: "吉林省",
  68. style: style3
  69. }),
  70. themeUniqueIteme4 = new SuperMap.ThemeUniqueItem({
  71. unique: "内蒙古自治区",
  72. style: style4
  73. }),
  74. themeUniqueIteme5 = new SuperMap.ThemeUniqueItem({
  75. unique: "青海省",
  76. style: style5
  77. }),
  78. themeUniqueIteme6 = new SuperMap.ThemeUniqueItem({
  79. unique: "新疆维吾尔自治区",
  80. style: style6
  81. }),
  82. themeUniqueIteme7 = new SuperMap.ThemeUniqueItem({
  83. unique: "云南省",
  84. style: style1
  85. }),
  86. themeUniqueIteme8 = new SuperMap.ThemeUniqueItem({
  87. unique: "四川省",
  88. style: style4
  89. }),
  90. themeUniqueIteme9 = new SuperMap.ThemeUniqueItem({
  91. unique: "贵州省",
  92. style: style3
  93. }),
  94. themeUniqueIteme10 = new SuperMap.ThemeUniqueItem({
  95. unique: "甘肃省",
  96. style: style3
  97. }),
  98. themeUniqueIteme11 = new SuperMap.ThemeUniqueItem({
  99. unique: "宁夏回族自治区",
  100. style: style5
  101. }),
  102. themeUniqueIteme12 = new SuperMap.ThemeUniqueItem({
  103. unique: "重庆市",
  104. style: style6
  105. }),
  106. themeUniqueIteme13 = new SuperMap.ThemeUniqueItem({
  107. unique: "山东省",
  108. style: style1
  109. }),
  110. themeUniqueIteme14 = new SuperMap.ThemeUniqueItem({
  111. unique: "安徽省",
  112. style: style2
  113. }),
  114. themeUniqueIteme15 = new SuperMap.ThemeUniqueItem({
  115. unique: "江西省",
  116. style: style3
  117. }),
  118. themeUniqueIteme16 = new SuperMap.ThemeUniqueItem({
  119. unique: "浙江省",
  120. style: style4
  121. }),
  122. themeUniqueIteme17 = new SuperMap.ThemeUniqueItem({
  123. unique: "台湾省",
  124. style: style2
  125. }),
  126. themeUniqueIteme18 = new SuperMap.ThemeUniqueItem({
  127. unique: "江苏省",
  128. style: style6
  129. }),
  130. themeUniqueIteme19 = new SuperMap.ThemeUniqueItem({
  131. unique: "湖南省",
  132. style: style5
  133. }),
  134. themeUniqueIteme20 = new SuperMap.ThemeUniqueItem({
  135. unique: "河南省",
  136. style: style4
  137. }),
  138. themeUniqueIteme21 = new SuperMap.ThemeUniqueItem({
  139. unique: "河北省",
  140. style: style3
  141. }),
  142. themeUniqueIteme22 = new SuperMap.ThemeUniqueItem({
  143. unique: "福建省",
  144. style: style5
  145. }),
  146. themeUniqueIteme23 = new SuperMap.ThemeUniqueItem({
  147. unique: "广西壮族自治区",
  148. style: style6
  149. }),
  150. themeUniqueIteme24 = new SuperMap.ThemeUniqueItem({
  151. unique: "西藏自治区",
  152. style: style2
  153. }),
  154. themeUniqueIteme25 = new SuperMap.ThemeUniqueItem({
  155. unique: "广东省",
  156. style: style4
  157. }),
  158. themeUniqueIteme26 = new SuperMap.ThemeUniqueItem({
  159. unique: "山西省",
  160. style: style2
  161. }),
  162. themeUniqueIteme27 = new SuperMap.ThemeUniqueItem({
  163. unique: "陕西省",
  164. style: style1
  165. }),
  166. themeUniqueIteme28 = new SuperMap.ThemeUniqueItem({
  167. unique: "天津市",
  168. style: style5
  169. }),
  170. themeUniqueIteme29 = new SuperMap.ThemeUniqueItem({
  171. unique: "北京市",
  172. style: style2
  173. }),
  174. themeUniqueIteme30 = new SuperMap.ThemeUniqueItem({
  175. unique: "辽宁省",
  176. style: style1
  177. });
  178. var themeUniqueItemes = [
  179. themeUniqueIteme1, themeUniqueIteme2, themeUniqueIteme3, themeUniqueIteme4, themeUniqueIteme5,
  180. themeUniqueIteme6, themeUniqueIteme7, themeUniqueIteme8, themeUniqueIteme9, themeUniqueIteme10,
  181. themeUniqueIteme11, themeUniqueIteme12, themeUniqueIteme13, themeUniqueIteme14, themeUniqueIteme15,
  182. themeUniqueIteme16, themeUniqueIteme17, themeUniqueIteme18, themeUniqueIteme19, themeUniqueIteme20,
  183. themeUniqueIteme21, themeUniqueIteme22, themeUniqueIteme23, themeUniqueIteme24, themeUniqueIteme25,
  184. themeUniqueIteme26, themeUniqueIteme27, themeUniqueIteme28, themeUniqueIteme29, themeUniqueIteme30
  185. ];
  186. themeUnique = new SuperMap.ThemeUnique({
  187. uniqueExpression: "Name",
  188. items: themeUniqueItemes,
  189. defaultStyle: style1
  190. });
  191. themeParameters = new SuperMap.ThemeParameters({
  192. datasetNames: ["China_Province_pg"],
  193. dataSourceNames: ["China"],
  194. themes: [themeUnique]
  195. });
  196. themeService.getThemeInfo(themeParameters, function (serviceResult) {
  197. var result = serviceResult.result;
  198. if (result && result.newResourceID) {
  199. themeLayer = L.supermap.tiledMapLayer(url, {
  200. noWrap: true,
  201. cacheEnabled: false,
  202. transparent: true,
  203. layersID: result.newResourceID
  204. }).addTo(map);
  205. }
  206. });
  207. }
  208. </script>
  209. </body>
  210. </html>