ISuperMap.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <div>
  3. <el-dialog title="经纬度" :visible.sync="showLongitude" append-to-body width="80%" @close='close' >
  4. <el-input v-show="false" v-model="obj.longitude"></el-input>
  5. <el-input v-show="false" v-model="obj.latitude"></el-input>
  6. <Supermap ref="Supermap" style="width: 100%;height: 75vh;" :mapDiv="uuid" :mapSite="{doubleClickZoom:false}"
  7. :codes="['9fa5']" :isSideBySide="false" :showLatLng="showLL"></Supermap>
  8. <el-button type="primary" @click="closeDialog">确定</el-button>
  9. </el-dialog>
  10. <el-dialog title="线坐标" :visible.sync="showLongitudex" append-to-body @close='close' width="80%" >
  11. <Supermap ref="LineSupermap" style="width: 100%;height:75vh"
  12. :mapDiv="uuid" :mapSite="{doubleClickZoom:false}" :codes="['9fa5']" :isSideBySide="false"
  13. :showLineLatLng="showAreaLatLng"></Supermap>
  14. <el-button type="primary" @click="closeDialog">确定</el-button>
  15. </el-dialog>
  16. <el-dialog title="区域坐标" :visible.sync="showLongitudeq" @close='close' width="80%" >
  17. <Supermap ref="areaSupermap" style="width: 100%;height:75vh"
  18. :mapDiv="uuid" :mapSite="{doubleClickZoom:false}" :codes="['9fa5']"
  19. :isSideBySide="false" :showAreaLatLng="showAreaLatLng"></Supermap>
  20. <el-button type="primary" @click="closeDialog">确定</el-button>
  21. </el-dialog>
  22. <el-dialog :title="(sign===1?'经纬度':(sign===2?'线坐标':'区域坐标'))" :visible.sync="visible" append-to-body width="80%"
  23. @close='close'>
  24. <supermap ref="supermap" style="width: 100%; height: 75vh" :putSmUserID_layer="putSmUserID_layer"
  25. @showLatLng="showLatLng"></supermap>
  26. <el-button type="primary" @click="closeDialog">确定</el-button>
  27. </el-dialog>
  28. </div>
  29. </template>
  30. <script>
  31. import {getConfigKey} from "@/api/system/config";
  32. const uuidv4 = require("uuid/v4")
  33. import supermap from '@/views/components/supermap-2.5d';
  34. import Supermap from '@/views/components/supermap';
  35. export default {
  36. //基本地图
  37. name: "ISuperMap",
  38. components: {supermap, Supermap},
  39. data() {
  40. return {
  41. uuid: '',
  42. sign: undefined,
  43. title: "",
  44. visible: false,
  45. showLongitude: false,
  46. showLongitudex: false,
  47. showLongitudeq: false,
  48. obj: {
  49. longitude: undefined,
  50. latitude: undefined,
  51. xiantude: undefined,
  52. }
  53. };
  54. },
  55. methods: {
  56. putSmUserID_layer: function (entity) {
  57. },
  58. showAreaLatLng: function (latlng) {
  59. this.obj.xiantude = JSON.stringify(latlng);
  60. },
  61. showLatLng: function (val) {
  62. if (this.sign === 1) {
  63. this.obj.longitude = val.longitude;
  64. this.obj.latitude = val.latitude;
  65. }
  66. if (this.sign === 2 || this.sign === 3) {
  67. this.obj.xiantude = JSON.stringify(val.markerList);
  68. }
  69. },
  70. showLL: function (lat, lng) {
  71. this.obj.latitude = lat;
  72. this.obj.longitude = lng;
  73. },
  74. init(sign, form,NB,type) {
  75. const regex = /^\d+(\.\d+)?$/;
  76. if (this.$parent.form.longitude != null) {
  77. if (!regex.test(form.longitude) ) {
  78. this.$message.warning('无效字符');
  79. this.visible = false;
  80. this.$parent.ISuperMapvisible = false;
  81. this.$parent.form.latitude = null;
  82. this.$parent.form.longitude = null;
  83. }
  84. }
  85. if (this.$parent.form.latitude != null) {
  86. if (!regex.test(form.latitude)) {
  87. this.$message.warning('无效字符');
  88. this.visible = false;
  89. this.$parent.ISuperMapvisible = false;
  90. this.$parent.form.latitude = null;
  91. this.$parent.form.longitude = null;
  92. }
  93. }
  94. if(NB=='NB'){
  95. getConfigKey('supermapKey').then(response => {
  96. let isN = response.msg;
  97. if (isN === 'true') this.visible = true;
  98. if (isN === 'false') sign === 2 ? this.showLongitudex = true : (sign === 1 ? this.showLongitude = true : this.showLongitudeq = true);
  99. this.sign = sign;
  100. this.uuid = uuidv4();
  101. this.$nextTick(() => {
  102. //2.5d 线/区域 轨迹
  103. if ((this.sign === 2 && this.visible === true) || (this.sign === 3 && this.visible === true)) {
  104. const arr = JSON.parse(form.xiantude == undefined || form.xiantude == null ? "[]" : form.xiantude);
  105. setTimeout(() => {
  106. this.$refs.supermap.superMapInfo(this.sign, arr,NB);
  107. }, 2000);
  108. }
  109. }
  110. )
  111. })
  112. }
  113. else {
  114. getConfigKey('supermapKey').then(response => {
  115. let isN = response.msg;
  116. if (isN === 'true') this.visible = true;
  117. if (isN === 'false') sign === 2 ? this.showLongitudex = true : (sign === 1 ? this.showLongitude = true : this.showLongitudeq = true);
  118. this.sign = sign;
  119. this.uuid = uuidv4();
  120. this.$nextTick(() => {
  121. //2d 点
  122. if (this.sign === 1 && this.showLongitude === true) {
  123. setTimeout(() => {
  124. this.$refs.Supermap.clearM(false);
  125. if (form.longitude!==null && form.longitude!=='' && form.longitude!==undefined) {
  126. this.$refs.Supermap.setMarkers([{lng: form.longitude, lat: form.latitude, icon: "marker"}])
  127. }
  128. }, 2000);
  129. }
  130. // //2.5d 点
  131. // if (this.sign === 1 && this.visible === true) {
  132. // setTimeout(() => {
  133. // this.$refs.supermap.superMapInfo(this.sign, {longitude: form.longitude, latitude: form.latitude});
  134. // }, 2000)
  135. // }
  136. //2.5d 点
  137. if (this.sign === 1 && this.visible === true) {
  138. setTimeout(() => {
  139. this.$refs.supermap.superMapInfo(this.sign, {longitude: form.longitude, latitude: form.latitude});
  140. }, 2000);
  141. setTimeout(() => {
  142. this.$refs.supermap.loadRoad()
  143. }, 7000);
  144. }
  145. //2.5d 线/区域
  146. if ((this.sign === 2 && this.visible === true) || (this.sign === 3 && this.visible === true)) {
  147. const arr = JSON.parse(form.xiantude == undefined || form.xiantude == null ? "[]" : form.xiantude);
  148. const array = [];
  149. for (let i = 0; i < arr.length; i++) {
  150. array.push(arr[i].lng);
  151. array.push(arr[i].lat);
  152. }
  153. setTimeout(() => {
  154. this.$refs.supermap.superMapInfo(this.sign, {
  155. graphicsList: array && array.length > 0 ? array : [],
  156. color: "rgba(23,22,22,0)",
  157. withAlpha: 0.8
  158. });
  159. }, 2000)
  160. if (type == 1 || type == 2 || type == 3 || type ==6){
  161. setTimeout(() => {
  162. type == 1 ? this.$refs.supermap.loadLindi() : (type == 2 ? this.$refs.supermap.loadShuixi() : (type == 3 ? this.$refs.supermap.loadRoad() :this.$refs.supermap.loadNongtian()))
  163. }, 10000);
  164. }
  165. }
  166. //2d 线
  167. if (this.sign === 2 && this.showLongitudex === true) {
  168. const arr = JSON.parse(form.xiantude);
  169. setTimeout(() => {
  170. this.$refs.LineSupermap.setConnectList(arr && arr.length > 0 ? arr : [], "#1a1919");
  171. }, 2000)
  172. }
  173. //2d 区域
  174. if (this.sign === 3 && this.showLongitudeq === true) {
  175. const arr = JSON.parse(form.xiantude);
  176. setTimeout(() => {
  177. this.$refs.areaSupermap.setGraphicsList(
  178. arr && arr.length > 0 ? arr : [],
  179. "#1a1919");
  180. }, 2000)
  181. }
  182. }
  183. )
  184. })
  185. }
  186. },
  187. closeDialog() {
  188. if (this.obj.longitude || (this.obj.xiantude && JSON.parse(this.obj.xiantude).length > 0)) this.$emit('send', this.obj);
  189. this.visible = false;
  190. this.showLongitude = false;
  191. this.showLongitudex = false;
  192. this.showLongitudeq = false;
  193. },
  194. close() {
  195. this.$emit('send', true);
  196. this.visible = false;
  197. this.showLongitude = false;
  198. this.showLongitudex = false;
  199. this.showLongitudeq = false;
  200. },
  201. }
  202. };
  203. </script>