initMapInfo.ts 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import * as layer from 'ol/layer'
  2. import * as source from 'ol/source'
  3. // @ts-ignore
  4. import HaituImg from './images/bg-ocean.png'
  5. import store from '@/store/index'
  6. const isInternet = false
  7. const baseMapView = {
  8. center: [109.6915958479584, 19.111636735969318],
  9. projection: "EPSG:4326",
  10. zoom: 9
  11. // extent: [120.8953306326286,31.3667480047968,121.37735577911297,31.692561298253832]
  12. }
  13. const initBaseLayer = (obj: any) => {
  14. const layers: any = []
  15. obj.layersUrl.forEach((v: any) => {
  16. const s = new source.XYZ({
  17. projection: "EPSG:4326",
  18. url: v.url,
  19. })
  20. const l = new layer.Tile({
  21. source: s
  22. })
  23. if (v.extent?.length > 0) {
  24. l.setExtent(v.extent)
  25. }
  26. if (v.maxZoom) {
  27. l.setMaxZoom(v.maxZoom)
  28. }
  29. if (v.minZoom) {
  30. l.setMinZoom(v.minZoom)
  31. }
  32. layers.push(l)
  33. })
  34. const layerGroup = new layer.Group({
  35. layers: layers,
  36. visible: obj.visible,
  37. })
  38. layerGroup.set('_maxZoom', obj.maxZoom)
  39. layerGroup.set('_minZoom', obj.minZoom)
  40. layerGroup.set('_easyMapOl_layerName', obj.name)
  41. layerGroup.set('_label', obj.label)
  42. layerGroup.set('_img', obj.img)
  43. return layerGroup
  44. }
  45. const initInternet = (obj) => {
  46. const _layer = new layer.Tile({
  47. source: new source.XYZ({
  48. url: 'http://wprd0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&style=7&x={x}&y={y}&z={z}'
  49. }),
  50. visible: obj.visible,
  51. })
  52. _layer.set('_maxZoom', obj.maxZoom)
  53. _layer.set('_minZoom', obj.minZoom)
  54. _layer.set('_easyMapOl_layerName', obj.name)
  55. _layer.set('_label', obj.label)
  56. _layer.set('_img', obj.img)
  57. return _layer
  58. }
  59. const baseMapLayers = [
  60. {
  61. key: 'LT',
  62. name: 'base_LT',
  63. label: '陆图',
  64. maxZoom: 18,
  65. minZoom: 1,
  66. visible: true,
  67. img: HaituImg,
  68. layersUrl: [
  69. {
  70. url: `/${store.state.app.apiProxy.BaseMap1Api}/vec_c/wmts?tk=%E6%82%A8%E7%9A%84%E5%AF%86%E9%92%A5&service=WMTS&request=GetTile&version=1.0.0&layers=&styles=&tilematrixSet=c&format=tiles&height=256&width=256&layer=vec&style=default&opacity=1&zIndex=1&tilematrix={z}&tilerow={y}&tilecol={x}`,
  71. },
  72. {
  73. url: `/${store.state.app.apiProxy.BaseMap2Api}/mapserver/vmap/hn_bigdata_2018dt/getMAP?x={x}&y={y}&l={z}&styleId=hn_bigdata_2018dtys1&ratio=1&tilesize=256&clientVersion=jssdk_bate@%20leaflet%202.1.5`,
  74. extent: [108.50508936658522, 18.127326424708514, 111.09756659719326, 20.163718157197533]
  75. },
  76. {
  77. url: `/${store.state.app.apiProxy.BaseMap1Api}/cva_c/wmts?tk=%E6%82%A8%E7%9A%84%E5%AF%86%E9%92%A5&service=WMTS&request=GetTile&version=1.0.0&layers=&styles=&tilematrixSet=c&format=tiles&height=256&width=256&layer=cva&style=default&zIndex=1&tilematrix={z}&tilerow={y}&tilecol={x}`
  78. },
  79. ]
  80. },
  81. {
  82. key: 'HT',
  83. name: 'base_HT',
  84. label: '海图',
  85. maxZoom: 18,
  86. minZoom: 1,
  87. visible: false,
  88. img: HaituImg,
  89. layersUrl: [
  90. {
  91. url: `/${store.state.app.apiProxy.BaseMap1Api}/ter_c/wmts?tk=%E6%82%A8%E7%9A%84%E5%AF%86%E9%92%A5&service=WMTS&request=GetTile&version=1.0.0&layers=&styles=&tilematrixSet=c&format=tiles&height=256&width=256&layer=ter&style=default&tilematrix={z}&tilerow={y}&tilecol={x}`,
  92. },
  93. {
  94. url: `/${store.state.app.apiProxy.BaseMap3Api}/ime-cloud/rest/hainan_dem/wmts?service=WMTS&request=GetTile&version=1.0.0&layers=&styles=&tilematrixSet=default028mm&format=image%2Fjpgpng&height=256&width=256&layer=hainan_dem&style=default&minZoom=8&maxZoom=18&zIndex=4&bounds=17.17616389817063%2C106.9017014531631%2C21.04474386095089%2C113.04819115525501&tilematrix={z}&tilerow={y}&tilecol={x}`,
  95. maxZoom: 18,
  96. minZoom: 8,
  97. extent: [106.9017014531631, 17.17616389817063, 113.04819115525501, 21.04474386095089]
  98. },
  99. {
  100. url: `/${store.state.app.apiProxy.BaseMap1Api}/cta_c/wmts?tk=%E6%82%A8%E7%9A%84%E5%AF%86%E9%92%A5&service=WMTS&request=GetTile&version=1.0.0&layers=&styles=&tilematrixSet=c&format=tiles&height=256&width=256&layer=cta&style=default&tilematrix={z}&tilerow={y}&tilecol={x}`,
  101. },
  102. ]
  103. },
  104. {
  105. key: 'WXT',
  106. name: 'base_WXT',
  107. label: '卫星图',
  108. maxZoom: 18,
  109. minZoom: 1,
  110. visible: false,
  111. img: HaituImg,
  112. layersUrl: [
  113. {
  114. url: `/${store.state.app.apiProxy.BaseMap1Api}/img_c/wmts?tk=%E6%82%A8%E7%9A%84%E5%AF%86%E9%92%A5&service=WMTS&request=GetTile&version=1.0.0&layers=&styles=&tilematrixSet=c&format=tiles&height=256&width=256&layer=img&style=default&opacity=0.6&zIndex=1&tilematrix={z}&tilerow={y}&tilecol={x}`,
  115. },
  116. {
  117. url: `/${store.state.app.apiProxy.BaseMap3Api}/ime-cloud/rest/hainan_img_2018/wmts?service=WMTS&request=GetTile&version=1.0.0&layers=&styles=&tilematrixSet=default028mm&format=image%2Fjpgpng&height=256&width=256&layer=hainan_img_2018&style=default&minZoom=8&maxZoom=18&zIndex=4&bounds=13.257020557028%2C103.34794430865948%2C23.46552385201528%2C114.30558768331025&tilematrix={z}&tilerow={y}&tilecol={x}`,
  118. extent: [103.34794430865948, 13.257020557028, 114.30558768331025, 23.46552385201528]
  119. },
  120. {
  121. url: `/${store.state.app.apiProxy.BaseMap1Api}/cia_c/wmts?tk=%E6%82%A8%E7%9A%84%E5%AF%86%E9%92%A5&service=WMTS&request=GetTile&version=1.0.0&layers=&styles=&tilematrixSet=c&format=tiles&height=256&width=256&layer=cia&style=default&zIndex=4&tilematrix={z}&tilerow={y}&tilecol={x}`,
  122. },
  123. ]
  124. },
  125. {
  126. key: 'HYS',
  127. name: 'base_HYS',
  128. label: '黑元素',
  129. maxZoom: 18,
  130. minZoom: 1,
  131. visible: false,
  132. img: HaituImg,
  133. layersUrl: [
  134. {
  135. url: `/${store.state.app.apiProxy.BaseMap2Api}/mapserver/vmap/hn_bigdata_2018dt/getMAP?x={x}&y={y}&l={z}&styleId=hn_bigdata_2018dtys2&ratio=1&tilesize=256&clientVersion=jssdk_bate@%20leaflet%202.1.5`,
  136. },
  137. {
  138. url: `/${store.state.app.apiProxy.BaseMap1Api}/cta_c/wmts?tk=%E6%82%A8%E7%9A%84%E5%AF%86%E9%92%A5&service=WMTS&request=GetTile&version=1.0.0&layers=&styles=&tilematrixSet=c&format=tiles&height=256&width=256&layer=cta&style=default&tilematrix={z}&tilerow={y}&tilecol={x}`,
  139. },
  140. ]
  141. },
  142. ]
  143. export default {
  144. baseMapView,
  145. baseMapLayers,
  146. initBaseLayer,
  147. initInternet,
  148. isInternet
  149. }