xy-map 1.0.59 → 1.1.1

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.
Files changed (68) hide show
  1. package/demo.html +1 -0
  2. package/{src/image/marker.png → img/marker.42b5782a.png} +0 -0
  3. package/package.json +11 -47
  4. package/xy-map.common.js +67645 -0
  5. package/xy-map.css +1 -0
  6. package/xy-map.umd.js +67664 -0
  7. package/xy-map.umd.min.js +20 -0
  8. package/.browserslistrc +0 -3
  9. package/.eslintignore +0 -1
  10. package/.eslintrc.js +0 -29
  11. package/README.md +0 -36
  12. package/babel.config.js +0 -3
  13. package/jsconfig.json +0 -12
  14. package/lint-staged.config.js +0 -3
  15. package/public/draco/README.md +0 -32
  16. package/public/draco/draco_decoder.js +0 -52
  17. package/public/draco/draco_decoder.wasm +0 -0
  18. package/public/draco/draco_encoder.js +0 -33
  19. package/public/draco/draco_wasm_wrapper.js +0 -104
  20. package/public/draco/gltf/draco_decoder.js +0 -48
  21. package/public/draco/gltf/draco_decoder.wasm +0 -0
  22. package/public/draco/gltf/draco_encoder.js +0 -33
  23. package/public/draco/gltf/draco_wasm_wrapper.js +0 -104
  24. package/public/favicon.ico +0 -0
  25. package/public/img/MM.png +0 -0
  26. package/public/img/MM_D.png +0 -0
  27. package/public/img/MM_W.png +0 -0
  28. package/public/img/loading.gif +0 -0
  29. package/public/img/waternormals.jpg +0 -0
  30. package/public/index.html +0 -29
  31. package/src/App.vue +0 -13
  32. package/src/image/arrow_white.png +0 -0
  33. package/src/image/map_end.png +0 -0
  34. package/src/image/map_start.png +0 -0
  35. package/src/index.js +0 -154
  36. package/src/layers/Line.js +0 -203
  37. package/src/layers/Point.js +0 -384
  38. package/src/layers/Polygon.js +0 -119
  39. package/src/layers/Text.js +0 -53
  40. package/src/layers/circle.js +0 -148
  41. package/src/layers/circleAnimate.js +0 -147
  42. package/src/layers/index.js +0 -128
  43. package/src/layers/model copy.js +0 -314
  44. package/src/layers/model.js +0 -341
  45. package/src/layers/scene.js +0 -314
  46. package/src/layers/water.js +0 -239
  47. package/src/map.js +0 -486
  48. package/src/package/draw/index.vue +0 -239
  49. package/src/package/draw/line.vue +0 -172
  50. package/src/package/draw/point.vue +0 -152
  51. package/src/package/draw/polygon.vue +0 -172
  52. package/src/package/draw/shpFile.vue +0 -49
  53. package/src/package/draw/styles.js +0 -162
  54. package/src/package/mapFullScreen.vue +0 -105
  55. package/src/package/mapLoad.vue +0 -120
  56. package/src/package/mapMarker.vue +0 -50
  57. package/src/package/mapModel.vue +0 -69
  58. package/src/package/mapRain.vue +0 -110
  59. package/src/style/hoverHtml.css +0 -29
  60. package/src/style/main.scss +0 -186
  61. package/src/style/map.css +0 -7
  62. package/src/util/gaodeApi.js +0 -67
  63. package/src/util/mapEvent.js +0 -111
  64. package/src/util/mapHoverHtml.js +0 -59
  65. package/src/util/mapTools.js +0 -169
  66. package/src/util/measure-area.js +0 -215
  67. package/src/util/measure-distance.js +0 -600
  68. package/vue.config.js +0 -32
@@ -1,239 +0,0 @@
1
- <template>
2
- <div class="tools">
3
- <div class="tools-bar flex flex-align-center">
4
- <div @click="startDraw('move')"
5
- :class="{'main-color': type === 'move'}"
6
- title="移动">
7
- <i class="el-icon-rank mr-5"></i>移动
8
- </div>
9
- <div class="ml-20"
10
- :class="{'main-color': item.type === type}"
11
- :title="item.name"
12
- :label="item.type"
13
- v-for="item in action"
14
- :key="item.type"
15
- @click="startDraw(item.type)">
16
- <i class="mr-5"
17
- :class="item.icon"></i>{{item.name}}
18
- </div>
19
-
20
- <template v-if="showDeleteBtn">
21
- <div class="ml-20"
22
- @click="drawDelete"
23
- title="删除">
24
- <i class="el-icon-close mr-5"></i>删除
25
- </div>
26
- <div class="ml-20"
27
- @click="clear"
28
- title="清空">
29
- <i class="el-icon-delete mr-5"></i>清空
30
- </div>
31
- </template>
32
-
33
- <map-full-screen class="ml-20"
34
- :dom="fullDom"
35
- v-if="showFullBtn">
36
- </map-full-screen>
37
- </div>
38
-
39
- <div class="margin-top flex"
40
- v-if="showMoveInput">
41
- <div class="flex flex-align-center">
42
- <span class="flex-child-noshrink">纬度:</span>
43
- <el-input size="small"
44
- v-model="lng"
45
- placeholder="请输入纬度" />
46
- </div>
47
- <div class="flex flex-align-center margin-left">
48
- <span class="flex-child-noshrink">经度:</span>
49
- <el-input size="small"
50
- v-model="lat"
51
- placeholder="请输入经度" />
52
- </div>
53
- <div class="margin-left">
54
- <el-button size="small"
55
- type="primary"
56
- @click="search">移动</el-button>
57
- </div>
58
- </div>
59
-
60
- <slot></slot>
61
- </div>
62
- </template>
63
-
64
- <script>
65
- import mapFullScreen from '../mapFullScreen.vue'
66
- import MapboxDraw from '@mapbox/mapbox-gl-draw'
67
- import '@mapbox/mapbox-gl-draw/dist/mapbox-gl-draw.css'
68
- // import styles from './styles'
69
-
70
- export default {
71
- components: {
72
- mapFullScreen
73
- },
74
- props: {
75
- fullDom: {
76
- type: String,
77
- default: 'fullScreen',
78
- },
79
- list: {
80
- type: Array,
81
- default: () => [],
82
- },
83
- single: { // 每次绘制前先清空画布
84
- type: Boolean,
85
- default: true,
86
- },
87
- showFullBtn: { // 全屏按钮
88
- type: Boolean,
89
- default: true,
90
- },
91
- showDeleteBtn: { // 删除按钮
92
- type: Boolean,
93
- default: true,
94
- },
95
- showMoveInput: { // 移动定位输入框
96
- type: Boolean,
97
- default: true
98
- }
99
- },
100
- data () {
101
- return {
102
- type: 'move',
103
- isEdit: false, //是否编辑模式
104
- draw: '',
105
- activeFeatures: '',
106
- lng: '',
107
- lat: ''
108
- }
109
- },
110
- computed: {
111
- action () {
112
- let arr = [
113
- { id: 'point', type: 'draw_point', name: '绘制点', icon: 'el-icon-coordinate' },
114
- { id: 'line', type: 'draw_line_string', name: '绘制线', icon: 'el-icon-arrow-up' },
115
- { id: 'polygon', type: 'draw_polygon', name: '绘制面', icon: 'el-icon-house' },
116
- // { id: 'circle', type: 'draw_circle', name: '绘制圆', icon: 'el-icon-pie-chart' },
117
- ]
118
- let filter = this.list.length > 0 ? arr.filter(item => this.list.includes(item.id)) : arr
119
- return filter
120
- }
121
- },
122
- methods: {
123
- initDraw (map) {
124
- this.map = map
125
- const draw = this.draw = new MapboxDraw({
126
- displayControlsDefault: false,
127
- controls: {
128
- // point: true,
129
- // line: true,
130
- // polygon: true,
131
- // trash: true
132
- }
133
- })
134
- map.addControl(draw)
135
- // map.drawControl.changeMode('draw_polygon')
136
-
137
- map.on('draw.create', this.drawEnd)
138
- map.on('draw.update', this.drawUpdate)
139
- map.on('draw.selectionchange', this.select)
140
- this.getCenter()
141
-
142
- // map.on('draw.modechange', (e) => {
143
- // const data = draw.getAll()
144
- // console.log('datadata')
145
- // console.log(data)
146
- // console.log(draw.getMode())
147
- // if (draw.getMode() == 'draw_polygon') {
148
- // if (data.features.length > 1) {
149
- // draw.deleteAll()
150
- // }
151
- // }
152
- // })
153
- },
154
- getDraw () { // 获取绘制内容
155
- const data = this.draw.getAll()
156
- return data
157
- },
158
- startDraw (type) {
159
- this.type = type
160
- if (type === 'move') return
161
- if (this.single) {
162
- this.clear()
163
- }
164
- console.log('开始绘制')
165
- this.draw.changeMode(type)
166
- this.$emit('start')
167
- },
168
- drawEnd (e) {
169
- // console.log(e)
170
- const data = this.getDraw()
171
- console.log('绘制结束', data)
172
- this.type = 'move'
173
- this.$emit('end', data)
174
- },
175
- drawUpdate (e) {
176
- // console.log(e)
177
- const data = this.getDraw()
178
- console.log('修改结束', data)
179
- this.$emit('update', data)
180
- },
181
- drawEdit (geometry) { // 修改回填元素
182
- // let geometry = {
183
- // type: 'Point',
184
- // coordinates: [this.lng, this.lat]
185
- // }
186
- this.draw.add(geometry)
187
- },
188
- drawDelete () { // 删除选中对象
189
- if (this.activeFeatures && this.activeFeatures.length > 0) {
190
- this.activeFeatures.forEach(item => {
191
- this.draw.delete(item.id)
192
- const data = this.getDraw()
193
- console.log('删除选中对象', data)
194
- this.$emit('delete', data)
195
- })
196
- } else {
197
- this.$message.warning('未选择删除的对象')
198
- }
199
- },
200
- clear () {
201
- if (this.draw) {
202
- this.draw.deleteAll()
203
- this.$emit('clear')
204
- }
205
- },
206
- select (e) {
207
- this.activeFeatures = e.features
208
- console.log('选中对象', this.activeFeatures)
209
- this.$emit('select', e.features)
210
- },
211
- search () {
212
- this.map.easeTo({
213
- center: [this.lng, this.lat],
214
- })
215
- },
216
- getCenter () {
217
- const { lng, lat } = this.map.getCenter()
218
- this.lng = lng
219
- this.lat = lat
220
- }
221
- }
222
- }
223
- </script>
224
-
225
- <style lang="scss" scoped>
226
- .tools {
227
- position: absolute;
228
- left: 0;
229
- top: 0;
230
- margin: 15px;
231
- background-color: rgba(255, 255, 255, 0.9);
232
- padding: 14px;
233
- border-radius: 5px;
234
-
235
- .tools-bar {
236
- cursor: pointer;
237
- }
238
- }
239
- </style>
@@ -1,172 +0,0 @@
1
- <template>
2
- <div id="fullScreen"
3
- class="full-height relative overflow">
4
- <div id="map"
5
- class="full-height"></div>
6
-
7
- <draw-tools ref="draw"
8
- :list="['line']"
9
- :single="single"
10
- :showMoveInput="showMoveInput"
11
- :showFullBtn="showFullBtn"
12
- @update="drawUpdate"
13
- @end="drawUpdate"
14
- @clear="clear">
15
- <div class="mt-15 flex">
16
- <el-input :value="position.toString()"
17
- size="small"
18
- placeholder="点击地图获取坐标"
19
- :readonly="readonly"
20
- style="width: 300px; margin-right: 10px;">
21
- </el-input>
22
-
23
- <shp-file v-if="upload"
24
- @upload="getShp"></shp-file>
25
-
26
- <el-button type="primary"
27
- size="small"
28
- @click="save">保存</el-button>
29
- </div>
30
- </draw-tools>
31
- </div>
32
- </template>
33
-
34
- <script>
35
- import { mapSdk } from '../../index.js'
36
- import drawTools from './index.vue'
37
- import shpFile from './shpFile.vue'
38
-
39
- export default {
40
- components: {
41
- drawTools,
42
- shpFile
43
- },
44
- props: {
45
- config: {
46
- type: Object,
47
- default: () => { }
48
- },
49
- readonly: {
50
- type: Boolean,
51
- default: false
52
- },
53
- upload: {
54
- type: Boolean,
55
- default: false
56
- },
57
- autoZoom: { // 自动缩放适应边界
58
- type: Boolean,
59
- default: false
60
- },
61
- single: {
62
- type: Boolean,
63
- default: false
64
- },
65
- geoData: {
66
- type: [Object, String],
67
- default: ''
68
- },
69
- pointList: {
70
- type: [Array, String],
71
- default: ''
72
- },
73
- showFullBtn: { // 全屏按钮
74
- type: Boolean,
75
- default: true,
76
- },
77
- showMoveInput: { // 移动定位输入框
78
- type: Boolean,
79
- default: false,
80
- }
81
- },
82
- data () {
83
- return {
84
- geoJson: '',
85
- position: '',
86
- }
87
- },
88
- watch: {
89
- pointList () {
90
- this.draw()
91
- },
92
- geoData () {
93
- this.draw()
94
- }
95
- },
96
- mounted () {
97
- this.init()
98
- },
99
- methods: {
100
- init () {
101
- let config = Object.assign({}, {
102
- accessToken: 'pk.eyJ1IjoiaGo0NjI3NzEzOTYiLCJhIjoiY2w5YzNjOTZvMDF6NDNwb2d6YmJkYWRpMCJ9.-fW-OChGB1oY2DCMO_c8sg',
103
- zoom: 14,
104
- center: [102.83643451528434, 24.81972792178513],
105
- is3d: false,
106
- }, this.config)
107
- mapSdk.initMap(config).then(map => {
108
- this.$refs.draw.initDraw(map)
109
- this.draw()
110
- })
111
- },
112
- draw () {
113
- if (this.pointList && this.pointList.length > 0) {
114
- let features = this.pointList.map(item => {
115
- return {
116
- 'type': 'Feature',
117
- 'geometry': {
118
- 'type': 'LineString',
119
- 'coordinates': item
120
- },
121
- 'properties': {}
122
- }
123
- })
124
- this.geoJson = {
125
- 'type': 'FeatureCollection',
126
- 'features': features
127
- }
128
- } else {
129
- this.geoJson = this.geoData
130
- }
131
- this.drawUpdate(this.geoJson, true)
132
- this.edit()
133
- },
134
- edit () { // 开启编辑
135
- if (this.geoJson) {
136
- this.$refs.draw.drawEdit(this.geoJson)
137
- }
138
- },
139
- drawUpdate (data, autoZoom = false) {
140
- if (!data) return
141
- this.geoJson = data
142
- this.position = data.features.map(item => item.geometry.coordinates)
143
-
144
- if (this.autoZoom || autoZoom) { // 开启缩放动画
145
- this.$nextTick(() => {
146
- const bounds = this.position.flat() // 二维数组转一维数组
147
- mapSdk.fitLineBounds(bounds, {
148
- padding: 100
149
- })
150
- })
151
- }
152
- },
153
- save () {
154
- let data = {
155
- geoJson: this.geoJson,
156
- position: this.position
157
- }
158
- console.log(data)
159
- this.$emit('save', data)
160
- },
161
- clear () {
162
- this.geoJson = ''
163
- this.position = ''
164
- },
165
- getShp (shp) {
166
- this.$refs.draw.clear() // 先清空画布
167
- this.drawUpdate(shp, true)
168
- this.edit()
169
- }
170
- }
171
- }
172
- </script>
@@ -1,152 +0,0 @@
1
- <template>
2
- <div id="fullScreen"
3
- class="full-height relative overflow">
4
- <div id="map"
5
- class="full-height"></div>
6
-
7
- <draw-tools ref="draw"
8
- :list="['point']"
9
- :showFullBtn="showFullBtn"
10
- :showMoveInput="showMoveInput"
11
- @update="drawUpdate"
12
- @end="drawUpdate"
13
- @clear="clear">
14
- <div class="mt-15"
15
- style="width: 380px;">
16
- <div class="flex">
17
- <el-input :value="position.toString()"
18
- size="small"
19
- placeholder="点击地图获取坐标"
20
- readonly
21
- class="full-width margin-right"></el-input>
22
- <el-button type="primary"
23
- size="small"
24
- @click="save">保存</el-button>
25
- </div>
26
- <div class="margin-top font-12"
27
- v-if="address && address.formattedAddress">地址:{{address.formattedAddress}}</div>
28
- </div>
29
- </draw-tools>
30
- </div>
31
- </template>
32
-
33
- <script>
34
- import { mapSdk } from '../../index.js'
35
- import drawTools from './index.vue'
36
- import { GeoAddress } from '../../util/gaodeApi.js'
37
-
38
- export default {
39
- components: {
40
- drawTools
41
- },
42
- props: {
43
- config: {
44
- type: Object,
45
- default: () => { }
46
- },
47
- geoData: {
48
- type: [Object, String],
49
- default: ''
50
- },
51
- lng: {
52
- type: [Number, String],
53
- default: ''
54
- },
55
- lat: {
56
- type: [Number, String],
57
- default: ''
58
- },
59
- showFullBtn: { // 全屏按钮
60
- type: Boolean,
61
- default: true,
62
- },
63
- showMoveInput: { // 移动定位输入框
64
- type: Boolean,
65
- default: false,
66
- }
67
- },
68
- data () {
69
- return {
70
- geoJson: '',
71
- position: '',
72
- address: '',
73
- }
74
- },
75
- watch: {
76
- lng () {
77
- this.draw()
78
- },
79
- geoData () {
80
- this.draw()
81
- }
82
- },
83
- mounted () {
84
- this.init()
85
- },
86
- methods: {
87
- init () {
88
- let config = Object.assign({}, {
89
- accessToken: 'pk.eyJ1IjoiaGo0NjI3NzEzOTYiLCJhIjoiY2w5YzNjOTZvMDF6NDNwb2d6YmJkYWRpMCJ9.-fW-OChGB1oY2DCMO_c8sg',
90
- zoom: 14,
91
- center: [102.83643451528434, 24.81972792178513],
92
- is3d: false,
93
- }, this.config)
94
- mapSdk.initMap(config).then(map => {
95
- this.$refs.draw.initDraw(map)
96
- this.draw()
97
- })
98
- },
99
- draw () {
100
- if (this.lng && this.lat) {
101
- this.geoJson = {
102
- 'type': 'FeatureCollection',
103
- 'features': [
104
- {
105
- 'type': 'Feature',
106
- 'geometry': {
107
- 'type': 'Point',
108
- 'coordinates': [this.lng * 1, this.lat * 1]
109
- },
110
- 'properties': {}
111
- }
112
- ]
113
- }
114
- } else {
115
- this.geoJson = this.geoData
116
- }
117
- this.drawUpdate(this.geoJson)
118
-
119
- // 开启编辑
120
- this.geoJson.features.forEach(item => {
121
- this.$refs.draw.drawEdit(item.geometry)
122
- })
123
- },
124
- drawUpdate (data) {
125
- this.geoJson = data
126
- this.position = data.features[0].geometry.coordinates
127
- this.$nextTick(() => {
128
- mapSdk.easeTo(this.position)
129
- GeoAddress(this.position).then(data => {
130
- this.address = data
131
- })
132
- })
133
- },
134
- save () {
135
- let data = {
136
- geoJson: this.geoJson,
137
- position: this.position,
138
- lng: this.position[0],
139
- lat: this.position[1],
140
- address: this.address
141
- }
142
- console.log(data)
143
- this.$emit('save', data)
144
- },
145
- clear () {
146
- this.geoJson = ''
147
- this.position = ''
148
- this.address = ''
149
- },
150
- }
151
- }
152
- </script>