ry-vue-map 0.2.8 → 0.3.0
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/lib/ryui.common.js +1056 -70
- package/lib/ryui.common.js.gz +0 -0
- package/lib/ryui.css +1 -1
- package/lib/ryui.css.gz +0 -0
- package/lib/ryui.umd.js +1056 -70
- package/lib/ryui.umd.js.gz +0 -0
- package/lib/ryui.umd.min.js +3 -3
- package/lib/ryui.umd.min.js.gz +0 -0
- package/package.json +1 -1
- package/src/assets/mask.png +0 -0
- package/src/assets/play.png +0 -0
- package/src/assets/stop.png +0 -0
- package/src/components/index.js +20 -1
- package/src/components/maps/models/ryLines/ryLines.js +17 -1
- package/src/components/maps/models/ryPolygons/ryPolygons.js +122 -122
- package/src/components/maps/models/ryStaticLayer/index.js +29 -0
- package/src/components/maps/models/ryStaticLayers/index.js +45 -0
- package/src/components/maps/ryLines/src/index.scss +115 -0
- package/src/components/maps/ryLines/src/index.vue +378 -26
- package/src/components/maps/ryStaticLayer/index.js +7 -0
- package/src/components/maps/ryStaticLayer/src/index.vue +154 -0
- package/src/components/maps/ryStaticLayers/index.js +7 -0
- package/src/components/maps/ryStaticLayers/src/index.vue +213 -0
- package/src/components/maps/switchMap/src/newIndex.vue +0 -1
- package/src/views/map/index.vue +430 -76
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
</template>
|
|
3
|
+
|
|
4
|
+
<script>
|
|
5
|
+
import {
|
|
6
|
+
fitNew,
|
|
7
|
+
GPS,
|
|
8
|
+
staticImage as StaticImage
|
|
9
|
+
} from 'ry-map';
|
|
10
|
+
import Dto from './../../models/ryStaticLayers/index.js';
|
|
11
|
+
export default {
|
|
12
|
+
name: 'RyStaticLayers',
|
|
13
|
+
props: {
|
|
14
|
+
...new Dto(),
|
|
15
|
+
},
|
|
16
|
+
data() {
|
|
17
|
+
return {
|
|
18
|
+
bbox: [],
|
|
19
|
+
bboxMap: new Map(),
|
|
20
|
+
bboxGCJ02: [],
|
|
21
|
+
bboxMapGCJ02: new Map(),
|
|
22
|
+
staticMap: new Map(),
|
|
23
|
+
isCreate: true,
|
|
24
|
+
lastType: -1,
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
watch: {
|
|
28
|
+
modelArr(val) {
|
|
29
|
+
this._remove();
|
|
30
|
+
if (!val.length) return;
|
|
31
|
+
this.modelArr = val;
|
|
32
|
+
this.init(val);
|
|
33
|
+
},
|
|
34
|
+
gpsType(val) {
|
|
35
|
+
if (this.lastType == val) return;
|
|
36
|
+
this.gpsType = val;
|
|
37
|
+
this.lastType = val;
|
|
38
|
+
this.selectGPSAll(this.gpsType);
|
|
39
|
+
},
|
|
40
|
+
insert(val) {
|
|
41
|
+
this.insert = val;
|
|
42
|
+
this._insert(val);
|
|
43
|
+
if(this.isFit){
|
|
44
|
+
setTimeout(() => {
|
|
45
|
+
this.setFit();
|
|
46
|
+
}, 50);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
inserts(val) {
|
|
50
|
+
this.inserts = val;
|
|
51
|
+
this._inserts(val);
|
|
52
|
+
},
|
|
53
|
+
clear(val) {
|
|
54
|
+
if (val) {
|
|
55
|
+
this._remove();
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
isShowAll(val) {
|
|
59
|
+
if (val) {
|
|
60
|
+
this.showAll();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.hideAll();
|
|
64
|
+
},
|
|
65
|
+
isShow(val) {
|
|
66
|
+
if (!val) return;
|
|
67
|
+
this._isShow(val);
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
created() {
|
|
74
|
+
this.lastType = this.gpsType;
|
|
75
|
+
this.init(this.modelArr);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
methods: {
|
|
79
|
+
init(arr) {
|
|
80
|
+
// this._insert();
|
|
81
|
+
if (!arr || !arr.length) return;
|
|
82
|
+
arr.forEach(val => {
|
|
83
|
+
this._insert(val);
|
|
84
|
+
});
|
|
85
|
+
if(this.isFit){
|
|
86
|
+
setTimeout(() => {
|
|
87
|
+
this.setFit();
|
|
88
|
+
}, 50);
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
_inserts(arr) {
|
|
92
|
+
this.lastType = this.gpsType;
|
|
93
|
+
arr.forEach(val => {
|
|
94
|
+
this._insert(val, false);
|
|
95
|
+
});
|
|
96
|
+
if(this.isFit){
|
|
97
|
+
setTimeout(() => {
|
|
98
|
+
this.setFit();
|
|
99
|
+
}, 50);
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
_insert(dto) {
|
|
103
|
+
const {
|
|
104
|
+
id,
|
|
105
|
+
url,
|
|
106
|
+
bbox,
|
|
107
|
+
zIndex,
|
|
108
|
+
} = dto;
|
|
109
|
+
if (!this.staticMap.has(id)) {
|
|
110
|
+
const img = new StaticImage({
|
|
111
|
+
id,
|
|
112
|
+
url,
|
|
113
|
+
imageExtent:bbox,
|
|
114
|
+
zIndex,
|
|
115
|
+
type:this.gpsType
|
|
116
|
+
},
|
|
117
|
+
this.map);
|
|
118
|
+
this.staticMap.set(id, img);
|
|
119
|
+
}
|
|
120
|
+
this.setBBOXArr(dto.id, bbox);
|
|
121
|
+
},
|
|
122
|
+
setBBOXArr(id, bbox) {
|
|
123
|
+
if (!this.bboxMap.has(id)) {
|
|
124
|
+
this.bbox.push(bbox);
|
|
125
|
+
this.bboxMap.set(id, bbox);
|
|
126
|
+
}
|
|
127
|
+
if (!this.bboxMapGCJ02.has(id)) {
|
|
128
|
+
const _bboxGCJ02 = this.convertBBoxGCJ02(bbox);
|
|
129
|
+
this.bboxGCJ02.push(_bboxGCJ02);
|
|
130
|
+
this.bboxMapGCJ02.set(id, _bboxGCJ02);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
setFit() {
|
|
135
|
+
if (!this.bbox.length || !this.map) return;
|
|
136
|
+
if (this.bbox.length > 1) {
|
|
137
|
+
fitNew(this.map, this.gpsType == 1 ? this.bboxGCJ02 : this.bbox);
|
|
138
|
+
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
this.setFitFist(this.gpsType == 1 ? this.bboxGCJ02[0] : this.bbox[0]);
|
|
142
|
+
},
|
|
143
|
+
// bbox.length =1 执行此处
|
|
144
|
+
setFitFist(bbox) {
|
|
145
|
+
const bbox2 = [bbox[0], bbox[3], bbox[2], bbox[1]];
|
|
146
|
+
const bbox3 = [bbox[2], bbox[1], bbox[0], bbox[3]];
|
|
147
|
+
fitNew(this.map, [bbox2, bbox3]);
|
|
148
|
+
},
|
|
149
|
+
convertBBoxGCJ02(bbox) {
|
|
150
|
+
const pointArr = [];
|
|
151
|
+
const {
|
|
152
|
+
lat,
|
|
153
|
+
lon
|
|
154
|
+
} = GPS.gcj_encrypt(bbox[0], bbox[1]);
|
|
155
|
+
const {
|
|
156
|
+
lon: lon2,
|
|
157
|
+
lat: lat2
|
|
158
|
+
} = GPS.gcj_encrypt(bbox[2], bbox[3]);
|
|
159
|
+
pointArr.push(lon);
|
|
160
|
+
pointArr.push(lat);
|
|
161
|
+
pointArr.push(lon2);
|
|
162
|
+
pointArr.push(lat2);
|
|
163
|
+
return pointArr;
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
_remove() {
|
|
167
|
+
this.staticMap.forEach(val => {
|
|
168
|
+
val.removeImageLayer();
|
|
169
|
+
val = null;
|
|
170
|
+
});
|
|
171
|
+
this.staticMap.clear();
|
|
172
|
+
this.bboxMap.clear();
|
|
173
|
+
this.bbox = [];
|
|
174
|
+
this.bboxGCJ02 = [];
|
|
175
|
+
this.bboxMapGCJ02.clear();
|
|
176
|
+
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
selectGPSAll(type) {
|
|
180
|
+
this.staticMap.forEach(val=> {
|
|
181
|
+
val.selectGPS(type);
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
showAll() {
|
|
186
|
+
this.staticMap.forEach(val => val.show());
|
|
187
|
+
if (this.restFit) {
|
|
188
|
+
this._restFit();
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
hideAll() {
|
|
193
|
+
this.staticMap.forEach(val => val.hide());
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
_isShow(val) {
|
|
197
|
+
const id = val.id;
|
|
198
|
+
if (this.staticMap.has(id)) {
|
|
199
|
+
const img = this.staticMap.get(id);
|
|
200
|
+
if (val.show) {
|
|
201
|
+
img.show();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
img.hide();
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
},
|
|
209
|
+
}
|
|
210
|
+
</script>
|
|
211
|
+
|
|
212
|
+
<style>
|
|
213
|
+
</style>
|