xy-map 1.0.38 → 1.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xy-map",
3
- "version": "1.0.38",
3
+ "version": "1.0.39",
4
4
  "description": "地图组件",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -127,6 +127,7 @@ const mapEvent = {
127
127
  import mapMarker from './package/mapMarker.vue'
128
128
  import mapRain from './package/mapRain.vue'
129
129
  import mapLoad from './package/mapLoad.vue'
130
+ import mapFullScreen from './package/mapFullScreen.vue'
130
131
  import drawTools from './package/draw/index.vue'
131
132
  import drawPoint from './package/draw/point.vue'
132
133
  import drawLine from './package/draw/line.vue'
@@ -136,14 +137,13 @@ const mapComponent = {
136
137
  mapMarker,
137
138
  mapRain,
138
139
  mapLoad,
140
+ mapFullScreen,
139
141
  drawTools,
140
142
  drawPoint,
141
143
  drawLine,
142
144
  drawPolygon
143
145
  }
144
146
 
145
- // Vue.component('drawTools', mapLoad)
146
-
147
147
  export {
148
148
  mapSdk,
149
149
  mapLayers,
@@ -21,6 +21,11 @@
21
21
  title="清空">
22
22
  <i class="el-icon-delete mr-5"></i>清空
23
23
  </div>
24
+
25
+ <map-full-screen class="ml-20"
26
+ dom="fullScreen"
27
+ v-if="showFullBtn">
28
+ </map-full-screen>
24
29
  </div>
25
30
 
26
31
  <slot></slot>
@@ -28,11 +33,15 @@
28
33
  </template>
29
34
 
30
35
  <script>
36
+ import mapFullScreen from '../mapFullScreen.vue'
31
37
  import MapboxDraw from '@mapbox/mapbox-gl-draw'
32
38
  import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'
33
39
  // import styles from './styles'
34
40
 
35
41
  export default {
42
+ components: {
43
+ mapFullScreen
44
+ },
36
45
  props: {
37
46
  list: {
38
47
  type: Array,
@@ -41,6 +50,10 @@ export default {
41
50
  single: { // 每次绘制前先清空画布
42
51
  type: Boolean,
43
52
  default: true,
53
+ },
54
+ showFullBtn: { // 全屏按钮
55
+ type: Boolean,
56
+ default: true,
44
57
  }
45
58
  },
46
59
  data () {
@@ -129,6 +142,9 @@ export default {
129
142
  this.$emit('clear')
130
143
  }
131
144
  },
145
+ fullScreen () {
146
+
147
+ }
132
148
  }
133
149
  }
134
150
  </script>
@@ -1,11 +1,13 @@
1
1
  <template>
2
- <div class="full-height relative overflow">
2
+ <div id="fullScreen"
3
+ class="full-height relative overflow">
3
4
  <div id="map"
4
5
  class="full-height"></div>
5
6
 
6
7
  <draw-tools ref="draw"
7
8
  :list="['line']"
8
9
  :single="single"
10
+ :showFullBtn="showFullBtn"
9
11
  @update="drawUpdate"
10
12
  @end="drawUpdate"
11
13
  @clear="clear">
@@ -66,6 +68,10 @@ export default {
66
68
  type: [Array, String],
67
69
  default: ''
68
70
  },
71
+ showFullBtn: { // 全屏按钮
72
+ type: Boolean,
73
+ default: true,
74
+ }
69
75
  },
70
76
  data () {
71
77
  return {
@@ -120,10 +126,11 @@ export default {
120
126
  this.edit()
121
127
  },
122
128
  edit () { // 开启编辑
123
- if (this.geoJson && this.geoJson.features.length === 0) return
124
- this.geoJson.features.forEach(item => {
125
- this.$refs.draw.drawEdit(item.geometry)
126
- })
129
+ if (this.geoJson && this.geoJson.features.length > 0) {
130
+ this.geoJson.features.forEach(item => {
131
+ this.$refs.draw.drawEdit(item.geometry)
132
+ })
133
+ }
127
134
  },
128
135
  drawUpdate (data, autoZoom = false) {
129
136
  if (!data) return
@@ -1,10 +1,12 @@
1
1
  <template>
2
- <div class="full-height relative overflow">
2
+ <div id="fullScreen"
3
+ class="full-height relative overflow">
3
4
  <div id="map"
4
5
  class="full-height"></div>
5
6
 
6
7
  <draw-tools ref="draw"
7
8
  :list="['point']"
9
+ :showFullBtn="showFullBtn"
8
10
  @update="drawUpdate"
9
11
  @end="drawUpdate"
10
12
  @clear="clear">
@@ -53,6 +55,10 @@ export default {
53
55
  type: [Number, String],
54
56
  default: ''
55
57
  },
58
+ showFullBtn: { // 全屏按钮
59
+ type: Boolean,
60
+ default: true,
61
+ }
56
62
  },
57
63
  data () {
58
64
  return {
@@ -1,11 +1,13 @@
1
1
  <template>
2
- <div class="full-height relative overflow">
2
+ <div id="fullScreen"
3
+ class="full-height relative overflow">
3
4
  <div id="map"
4
5
  class="full-height"></div>
5
6
 
6
7
  <draw-tools ref="draw"
7
8
  :list="['polygon']"
8
9
  :single="single"
10
+ :showFullBtn="showFullBtn"
9
11
  @update="drawUpdate"
10
12
  @end="drawUpdate"
11
13
  @clear="clear">
@@ -66,6 +68,10 @@ export default {
66
68
  type: [Array, String],
67
69
  default: ''
68
70
  },
71
+ showFullBtn: { // 全屏按钮
72
+ type: Boolean,
73
+ default: true,
74
+ }
69
75
  },
70
76
  data () {
71
77
  return {
@@ -120,10 +126,11 @@ export default {
120
126
  this.edit()
121
127
  },
122
128
  edit () { // 开启编辑
123
- if (this.geoJson && this.geoJson.features.length === 0) return
124
- this.geoJson.features.forEach(item => {
125
- this.$refs.draw.drawEdit(item.geometry)
126
- })
129
+ if (this.geoJson && this.geoJson.features.length > 0) {
130
+ this.geoJson.features.forEach(item => {
131
+ this.$refs.draw.drawEdit(item.geometry)
132
+ })
133
+ }
127
134
  },
128
135
  drawUpdate (data, autoZoom = false) {
129
136
  if (!data) return
@@ -0,0 +1,105 @@
1
+ <template>
2
+ <span>
3
+ <span v-if="isSlot"
4
+ @click="handleFullScreen"
5
+ :title="isFullScreen ? '退出全屏' : '进入全屏'">
6
+ <slot></slot>
7
+ </span>
8
+ <span v-else
9
+ @click="handleFullScreen"
10
+ :title="isFullScreen ? '退出全屏' : '进入全屏'">
11
+ <i class="el-icon-full-screen mr-5"></i>
12
+ 全屏
13
+ </span>
14
+ </span>
15
+ </template>
16
+
17
+ <script>
18
+ export default {
19
+ props: {
20
+ isSlot: {
21
+ type: Boolean,
22
+ default: false
23
+ },
24
+ dom: {
25
+ type: String,
26
+ default: ''
27
+ }
28
+ },
29
+ data () {
30
+ return {
31
+ isFullScreen: false,
32
+ }
33
+ },
34
+ watch: {
35
+ isFullScreen (val) {
36
+ this.$emit('change', val)
37
+ }
38
+ },
39
+ methods: {
40
+ // 全屏
41
+ handleFullScreen () {
42
+ let mapMainContent
43
+ // 判断是否有dom传入,没有则是整个页面全屏展示
44
+ this.dom ? mapMainContent = document.getElementById(this.dom) : mapMainContent = document.documentElement
45
+ if (this.isFUllScreenEnabled()) {
46
+ if (this.hasFullScreenElement()) {
47
+ this.exitFullScreen()
48
+ this.isFullScreen = false
49
+ } else {
50
+ this.setFullScreen(mapMainContent)
51
+ this.isFullScreen = true
52
+ }
53
+ } else {
54
+ console.log('此浏览器不支持全屏')
55
+ }
56
+ },
57
+ // 判断浏览器是否支持全屏
58
+ isFUllScreenEnabled () {
59
+ return document.fullscreenEnabled || document.webkitFullscreenEnabled || document.mozFullScreenEnabled || document.msFullscreenEnabled
60
+ },
61
+ // 判断是否有已全屏的元素
62
+ hasFullScreenElement () {
63
+ return document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement
64
+ },
65
+ // 将目标元素设置为全屏展示
66
+ setFullScreen (target) {
67
+ if (target.requestFullscreen) {
68
+ target.requestFullscreen()
69
+ }
70
+ if (target.webkitRequestFullscreen) {
71
+ target.webkitRequestFullscreen()
72
+ }
73
+ if (target.mozRequestFullScreen) {
74
+ target.mozRequestFullScreen()
75
+ }
76
+ if (target.msRequestFullscreen) {
77
+ target.msRequestFullscreen()
78
+ }
79
+ },
80
+ // 文档退出全屏
81
+ exitFullScreen () {
82
+ if (document.exitFullscreen) {
83
+ document.exitFullscreen()
84
+ }
85
+ if (document.webkitExitFullscreen) {
86
+ document.webkitExitFullscreen()
87
+ }
88
+ if (document.mozCancelFullScreen) {
89
+ document.mozCancelFullScreen()
90
+ }
91
+ if (document.msExitFullscreen) {
92
+ document.msExitFullscreen()
93
+ }
94
+ }
95
+ }
96
+ }
97
+ </script>
98
+
99
+ <style lang="scss" scoped>
100
+ :fullscreen {
101
+ .d {
102
+ color: red;
103
+ }
104
+ }
105
+ </style>