ry-vue-map 0.2.1 → 0.2.2
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/README.MD +1 -1
- package/lib/ryui.common.js +464 -284
- package/lib/ryui.common.js.gz +0 -0
- package/lib/ryui.css +1 -1
- package/lib/ryui.umd.js +464 -284
- package/lib/ryui.umd.js.gz +0 -0
- package/lib/ryui.umd.min.js +4 -4
- package/lib/ryui.umd.min.js.gz +0 -0
- package/package.json +3 -2
- package/src/assets/moveMarker.png +0 -0
- package/src/assets/startpoint.png +0 -0
- package/src/assets/stoppoint.png +0 -0
- package/src/components/index.js +2 -1
- package/src/components/maps/models/ryLines/ryLines.js +73 -0
- package/src/components/maps/ryLines/index.js +7 -0
- package/src/components/maps/ryLines/src/index.vue +226 -0
- package/src/components/maps/ryMap/src/index.vue +1 -0
- package/src/components/maps/ryPolygons/src/index.vue +67 -67
- package/src/components/maps/ryUniMap/index.js +6 -0
- package/src/components/maps/ryUniMap/src/index.vue +351 -0
- package/src/router/index.js +3 -3
- package/src/utils/lMapServices.js +947 -924
- package/src/views/map/index.vue +220 -7
- package/src/views/map/lineData.js +19592 -0
- package/src/views/map/lineData2.js +3449 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="map-box">
|
|
3
|
+
<div class="map-style"></div>
|
|
4
|
+
<!-- isRyMapTool -->
|
|
5
|
+
<RyMapTool class="ry-map-tool" :class="{
|
|
6
|
+
'left':!isRight,
|
|
7
|
+
'right':isRight
|
|
8
|
+
}" v-if="lMap.map && isRyMapTool" @crossHairClick="crossHairClick($event)" :lMap="lMap"
|
|
9
|
+
:isShowRangingTool="isShowRangingTool" :initModifyPolygon="initModifyPolygon"
|
|
10
|
+
:isShowDrawTool="isShowDrawTool" :isRight="isRight" :isCrossHair="isCrossHair" :hideAdd="hideAdd"
|
|
11
|
+
:hidePoint="hidePoint" :hideCancel="hideCancel" :hideDelete="hideDelete" :hideSave="hideSave"
|
|
12
|
+
:hideLine="hideLine" :hideArea="hideArea" :isSwitchMap="isSwitchMap" :isSwitchMapRight="isSwitchMapRight"
|
|
13
|
+
:gpsType="lastMapType" @loadDrawPolygonEvent="loadDrawPolygonEvent($event)" @success="drawSuccess($event)"
|
|
14
|
+
@error="drawError($event)">
|
|
15
|
+
<template>
|
|
16
|
+
<slot name="maptool"></slot>
|
|
17
|
+
</template>
|
|
18
|
+
</RyMapTool>
|
|
19
|
+
|
|
20
|
+
<template v-if="map">
|
|
21
|
+
<slot name="polygon" :mapDto="{map,lMap}">
|
|
22
|
+
|
|
23
|
+
</slot>
|
|
24
|
+
|
|
25
|
+
<slot name="marker" :mapDto="{map,lMap}">
|
|
26
|
+
|
|
27
|
+
</slot>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<SwitchMap
|
|
31
|
+
v-if="isSwitchMapTool && isShowSwitchMap"
|
|
32
|
+
:height="switchMapHeight"
|
|
33
|
+
:switchMapDefaultTypeOrLayer="switchMapDefaultTypeOrLayer"
|
|
34
|
+
:mapTypeAndLayer="mapTypeAndLayer"
|
|
35
|
+
class="move-box" :style="{
|
|
36
|
+
top:switchMapPosTop + 'px',
|
|
37
|
+
right:isSwitchMapRight?switchMapPosLeftOrRight + 'px':'none',
|
|
38
|
+
left:!isSwitchMapRight?switchMapPosLeftOrRight + 'px':'none'
|
|
39
|
+
}" :bottom-right="isSwitchMapRight"
|
|
40
|
+
@changeSwitchMap="changeSwitchMap"
|
|
41
|
+
:isDisabled= "isDisabledSwitchMapTabEvent"
|
|
42
|
+
/>
|
|
43
|
+
|
|
44
|
+
<!-- 'current': !isRyMapTool || !isRight -->
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
</template>
|
|
50
|
+
<script>
|
|
51
|
+
import MapServices from '@/utils/lMapServices.js';
|
|
52
|
+
import MapDto from './../../models/ryMap/map.js';
|
|
53
|
+
import ViewDto from './../../models/ryMap/view.js';
|
|
54
|
+
import MapToolDto from './../../models/ryMapTool/mapTool.js';
|
|
55
|
+
import RyMapTool from '../../ryMapTool/src/index';
|
|
56
|
+
import SwitchMap from '../../switchMap/src/newIndex';
|
|
57
|
+
import {
|
|
58
|
+
ViewOptions,
|
|
59
|
+
fitNew,
|
|
60
|
+
caculateLL,
|
|
61
|
+
GPS
|
|
62
|
+
} from 'ry-map';
|
|
63
|
+
export default {
|
|
64
|
+
name: 'RyUniMap',
|
|
65
|
+
components: {
|
|
66
|
+
RyMapTool,
|
|
67
|
+
SwitchMap,
|
|
68
|
+
},
|
|
69
|
+
props: {
|
|
70
|
+
target:{
|
|
71
|
+
type:Object,
|
|
72
|
+
default:()=> null,
|
|
73
|
+
|
|
74
|
+
},
|
|
75
|
+
...new MapDto(),
|
|
76
|
+
...new ViewDto(),
|
|
77
|
+
...new MapToolDto()
|
|
78
|
+
},
|
|
79
|
+
created() {},
|
|
80
|
+
watch: {
|
|
81
|
+
center(newValue) {
|
|
82
|
+
this.setCenter(newValue);
|
|
83
|
+
},
|
|
84
|
+
bbox(newValue) {
|
|
85
|
+
this.setFit(newValue);
|
|
86
|
+
},
|
|
87
|
+
maxZoom(zoom) {
|
|
88
|
+
this.lMap.setMaxZoom(zoom);
|
|
89
|
+
},
|
|
90
|
+
zoom(zoom) {
|
|
91
|
+
this.lMap.setZoom(zoom);
|
|
92
|
+
},
|
|
93
|
+
minZoom(zoom) {
|
|
94
|
+
this.lMap.setMinZoom(zoom);
|
|
95
|
+
},
|
|
96
|
+
bindMapClick(val) {
|
|
97
|
+
if (this.bindMapClick !== val) {
|
|
98
|
+
this.bindMapClick = val;
|
|
99
|
+
this._bingMapEvent();
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
bindMapMoveend(val) {
|
|
103
|
+
if (this.bindMapMoveend !== val) {
|
|
104
|
+
this.bindMapMoveend = val;
|
|
105
|
+
this._bingMapMoveend();
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
m(val) {
|
|
109
|
+
this.m = val;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
created(){
|
|
113
|
+
|
|
114
|
+
},
|
|
115
|
+
data() {
|
|
116
|
+
return {
|
|
117
|
+
lMap: new MapServices(),
|
|
118
|
+
drawPolygon: null,
|
|
119
|
+
mapClick: null,
|
|
120
|
+
map: null,
|
|
121
|
+
moveend: null,
|
|
122
|
+
lastX: 0,
|
|
123
|
+
lastY: 0,
|
|
124
|
+
lastMapType: 0,
|
|
125
|
+
isFirstLoad: false,
|
|
126
|
+
};
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
methods: {
|
|
130
|
+
changeSwitchMap({
|
|
131
|
+
mapType,
|
|
132
|
+
layerType
|
|
133
|
+
}) {
|
|
134
|
+
|
|
135
|
+
this.lMap.selectMapLayer(mapType, layerType);
|
|
136
|
+
this._setMaxZoom(mapType, layerType);
|
|
137
|
+
let _mapType = mapType;
|
|
138
|
+
if (mapType > 1) {
|
|
139
|
+
_mapType = 0;
|
|
140
|
+
}
|
|
141
|
+
if (this.lastMapType == _mapType ) return;
|
|
142
|
+
|
|
143
|
+
this.lastMapType = _mapType;
|
|
144
|
+
|
|
145
|
+
const center = this.lMap.getCenter();
|
|
146
|
+
if (center && center.length) {
|
|
147
|
+
if (_mapType == 0) {
|
|
148
|
+
const {
|
|
149
|
+
lon,
|
|
150
|
+
lat
|
|
151
|
+
} = GPS.gcj_decrypt(center[0], center[1]);
|
|
152
|
+
this.lMap.setCenter([lon, lat]);
|
|
153
|
+
} else {
|
|
154
|
+
const {
|
|
155
|
+
lon,
|
|
156
|
+
lat
|
|
157
|
+
} = GPS.gcj_encrypt(center[0], center[1]);
|
|
158
|
+
this.lMap.setCenter([lon, lat]);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
this.$emit('changeSwitchMap', {
|
|
162
|
+
mapType: _mapType,
|
|
163
|
+
layerType,
|
|
164
|
+
type:mapType
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
_setMaxZoom(type, layerType) {
|
|
168
|
+
if (type == 2 || layerType == 0) {
|
|
169
|
+
this.setMaxZoom(28);
|
|
170
|
+
// return;
|
|
171
|
+
} else {
|
|
172
|
+
this.setMaxZoom(18);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
loadMap(el) {
|
|
176
|
+
// const dto =
|
|
177
|
+
this.lMap.init({
|
|
178
|
+
el,
|
|
179
|
+
type: this.mapType,
|
|
180
|
+
layerType: this.layerType,
|
|
181
|
+
viewOptions: this.getViewOptions(),
|
|
182
|
+
callback: (map,layers) => {
|
|
183
|
+
this.map = map;
|
|
184
|
+
|
|
185
|
+
if (this.bbox.length > 0) {
|
|
186
|
+
this.setFit(this.bbox);
|
|
187
|
+
}
|
|
188
|
+
try {
|
|
189
|
+
const [x, y] = this.lMap.getCenter();
|
|
190
|
+
this.lastX = x;
|
|
191
|
+
this.lastY = y;
|
|
192
|
+
} catch (err) {
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
this._bingMapEvent();
|
|
196
|
+
this._bingMapMoveend();
|
|
197
|
+
this.$emit('load', {
|
|
198
|
+
map,
|
|
199
|
+
mapServices: this.lMap,
|
|
200
|
+
layers,
|
|
201
|
+
ryMapTool: this.$refs.mapTool
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
if (!this.isShowSwitchMap) {
|
|
205
|
+
this.lastMapType = this.mapType > 2 ? 0 : this.mapType;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
_bingMapEvent() {
|
|
211
|
+
if (this.bindMapClick) {
|
|
212
|
+
this._mapClickOnce();
|
|
213
|
+
} else {
|
|
214
|
+
this._mapClickOnce(true);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
_bingMapMoveend() {
|
|
218
|
+
if (this.bindMapMoveend) {
|
|
219
|
+
this._mapMoveend();
|
|
220
|
+
} else {
|
|
221
|
+
this._mapMoveend(true);
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
getViewOptions() {
|
|
225
|
+
return {
|
|
226
|
+
projection: this.projection,
|
|
227
|
+
center: this.center,
|
|
228
|
+
zoom: this.zoom,
|
|
229
|
+
minZoom: this.minZoom,
|
|
230
|
+
maxZoom: this.maxZoom,
|
|
231
|
+
};
|
|
232
|
+
},
|
|
233
|
+
setMaxZoom(zoom) {
|
|
234
|
+
this.lMap.setMaxZoom(zoom)
|
|
235
|
+
},
|
|
236
|
+
setMinZoom(zoom) {
|
|
237
|
+
this.lMap.setMinZoom(zoom)
|
|
238
|
+
},
|
|
239
|
+
setZoom(zoom) {
|
|
240
|
+
this.lMap.setZoom(zoom);
|
|
241
|
+
},
|
|
242
|
+
crossHairClick(obj) {
|
|
243
|
+
this.$emit('crossHairClick', obj);
|
|
244
|
+
},
|
|
245
|
+
setCenter(center) {
|
|
246
|
+
this.lMap.setCenter(center, 15);
|
|
247
|
+
},
|
|
248
|
+
setFit(bbox) {
|
|
249
|
+
if (!bbox.length || !this.map) return;
|
|
250
|
+
fitNew(this.map, [bbox]);
|
|
251
|
+
},
|
|
252
|
+
drawSuccess(geo) {
|
|
253
|
+
this.$emit('drawSuccess', geo);
|
|
254
|
+
},
|
|
255
|
+
drawError(obj) {
|
|
256
|
+
this.$emit('drawError', obj);
|
|
257
|
+
},
|
|
258
|
+
_mapClickOnce(isBinClick = false) {
|
|
259
|
+
if (!this.mapClick) {
|
|
260
|
+
this.mapClick = evt => {
|
|
261
|
+
if (evt.dragging) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const pixel = this.map.getEventPixel(evt.originalEvent);
|
|
265
|
+
const hit = this.map.hasFeatureAtPixel(pixel);
|
|
266
|
+
if (hit) {
|
|
267
|
+
const _feature = this.map.forEachFeatureAtPixel(evt.pixel, feature => feature);
|
|
268
|
+
const _id = _feature.getId();
|
|
269
|
+
if (_id === undefined) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
this.$emit('mapClick', _id);
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
if (isBinClick) {
|
|
277
|
+
this.map.un('click', this.mapClick);
|
|
278
|
+
this.mapClick = null;
|
|
279
|
+
} else {
|
|
280
|
+
this.map.on('click', this.mapClick);
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
_mapMoveend(isMoveend = false) {
|
|
284
|
+
this.moveend = e => {
|
|
285
|
+
const [x, y] = this.lMap.getCenter();
|
|
286
|
+
let m = 0;
|
|
287
|
+
if (this.lastX !== x && this.lastY !== y) {
|
|
288
|
+
m = caculateLL(this.lastY, this.lastX, y, x);
|
|
289
|
+
this.$emit('mapMoveend', {
|
|
290
|
+
m,
|
|
291
|
+
oversteSetValue: m >= this.m ? true : false,
|
|
292
|
+
x,
|
|
293
|
+
y
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
if (m >= this.m) {
|
|
297
|
+
this.lastX = x;
|
|
298
|
+
this.lastY = y;
|
|
299
|
+
}
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
this.$emit('mapMoveend', {
|
|
303
|
+
m,
|
|
304
|
+
oversteSetValue: false,
|
|
305
|
+
x,
|
|
306
|
+
y
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
if (isMoveend) {
|
|
310
|
+
this.map.un('moveend', this.moveend);
|
|
311
|
+
} else {
|
|
312
|
+
this.map.on('moveend', this.moveend);
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
loadDrawPolygonEvent(e) {
|
|
316
|
+
this.$emit('loadDrawPolygonEvent', e);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
</script>
|
|
321
|
+
|
|
322
|
+
<style lang="scss" scoped>
|
|
323
|
+
.map-box {
|
|
324
|
+
height: 100%;
|
|
325
|
+
position: relative;
|
|
326
|
+
|
|
327
|
+
&>.map-style {
|
|
328
|
+
height: 100%;
|
|
329
|
+
position: relative;
|
|
330
|
+
width: 100%;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.ry-map-tool {
|
|
335
|
+
position: absolute;
|
|
336
|
+
top: 20px;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.left {
|
|
340
|
+
left: 30px;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.right {
|
|
344
|
+
right: 30px;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
.move-box {
|
|
349
|
+
position: absolute;
|
|
350
|
+
}
|
|
351
|
+
</style>
|
package/src/router/index.js
CHANGED
|
@@ -11,17 +11,17 @@ Vue.use(VueRouter);
|
|
|
11
11
|
const routes = [
|
|
12
12
|
{
|
|
13
13
|
path: '/',
|
|
14
|
-
component: () => import('@/views/
|
|
14
|
+
component: () => import('@/views/map'),
|
|
15
15
|
meta: { title: '地图' }
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
path: '/',
|
|
19
|
-
component: () => import('@/views/
|
|
19
|
+
component: () => import('@/views/vectorMap'),
|
|
20
20
|
meta: { title: '地图' }
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
path: '*',
|
|
24
|
-
component: () => import('@/views/
|
|
24
|
+
component: () => import('@/views/map'),
|
|
25
25
|
}
|
|
26
26
|
];
|
|
27
27
|
|