ry-vue-map 0.2.3 → 0.2.5
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 +34057 -29071
- package/lib/ryui.common.js.gz +0 -0
- package/lib/ryui.css +1 -1
- package/lib/ryui.umd.js +34057 -29071
- package/lib/ryui.umd.js.gz +0 -0
- package/lib/ryui.umd.min.js +5 -5
- package/lib/ryui.umd.min.js.gz +0 -0
- package/package.json +2 -2
- package/src/components/index.js +4 -1
- package/src/components/maps/models/ryKML/index.js +29 -0
- package/src/components/maps/models/ryKMLs/index.js +41 -0
- package/src/components/maps/models/ryOfflineMap/map.js +140 -0
- package/src/components/maps/models/ryOfflineMap/view.js +62 -0
- package/src/components/maps/ryKML/index.js +7 -0
- package/src/components/maps/ryKML/src/index.vue +174 -0
- package/src/components/maps/ryKMLs/index.js +7 -0
- package/src/components/maps/ryKMLs/src/index.vue +217 -0
- package/src/components/maps/ryOfflineMap/index.js +6 -0
- package/src/components/maps/ryOfflineMap/src/index.vue +329 -0
- package/src/components/maps/switchMap/src/newIndex.vue +1 -1
- package/src/main.js +10 -8
- package/src/utils/lMapServices.js +48 -24
- package/src/views/map/330112.js +220 -0
- package/src/views/map/index.vue +73 -91
- package/src/views/map/index3.vue +207 -0
- package/src/views/map/index4.vue +207 -0
- package/src/views/map/indexStatic.vue +205 -0
- package/src/views/staticMap/index.vue +0 -1
- package/src/views/vectorMap/index.vue +2 -2
package/lib/ryui.umd.min.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ry-vue-map",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "lib/ryui.umd.min.js",
|
|
6
6
|
"description": "ry公共组件库",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"element-ui": "~2.15.6",
|
|
44
44
|
"nprogress": "~0.2.0",
|
|
45
45
|
"ol": "^6.14.1",
|
|
46
|
-
"ry-map": "^0.
|
|
46
|
+
"ry-map": "^0.4.1",
|
|
47
47
|
"vue": "~2.6.14",
|
|
48
48
|
"vue-demi": "^0.13.11",
|
|
49
49
|
"vue-router": "~3.5.2",
|
package/src/components/index.js
CHANGED
|
@@ -10,10 +10,13 @@ import RyPolygonGeo from './maps/ryPolygonGeo';
|
|
|
10
10
|
import RyVectorMap from './maps/ryVectorMap';
|
|
11
11
|
import RyLines from './maps/ryLines';
|
|
12
12
|
import RyStaticMap from './maps/ryStaticMap/index';
|
|
13
|
+
import RyOfflineMap from './maps/ryOfflineMap/index';
|
|
14
|
+
import RyKMLs from './maps/ryKMLs/index';
|
|
15
|
+
import RyKML from './maps/ryKML/index';
|
|
13
16
|
// import "./fonts/iconfont.css";
|
|
14
17
|
|
|
15
18
|
// 组件列表
|
|
16
|
-
const components = [RyMap,RyCrossHair,RyMapTool, RyPolygon,RyPolygons,RyClusters, RyPolygonGeo, RyClustersMarker,RyVectorMap,RyLines,RyStaticMap];
|
|
19
|
+
const components = [RyMap,RyCrossHair,RyMapTool, RyPolygon,RyPolygons,RyClusters, RyPolygonGeo, RyClustersMarker,RyVectorMap,RyLines,RyStaticMap,RyOfflineMap,RyKMLs,RyKML];
|
|
17
20
|
|
|
18
21
|
// 定义install
|
|
19
22
|
const install = (Vue, options) => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
import Base from '../base/base';
|
|
3
|
+
|
|
4
|
+
export default class RyKMLDto extends Base {
|
|
5
|
+
// 多边形
|
|
6
|
+
model = {
|
|
7
|
+
type: Object,
|
|
8
|
+
default: () => null,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// 显示或隐藏
|
|
12
|
+
isShow = {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: true,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// 清除多边形以及标记
|
|
18
|
+
clear = {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: false,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// 是否根据bbox 设为中心点
|
|
24
|
+
isFit = {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: true,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
import Base from '../base/base';
|
|
3
|
+
|
|
4
|
+
export default class RyKMLDto extends Base {
|
|
5
|
+
// 多边形
|
|
6
|
+
modelArr = {
|
|
7
|
+
type: Array,
|
|
8
|
+
default: () => [],
|
|
9
|
+
};
|
|
10
|
+
// 插入
|
|
11
|
+
insert = {
|
|
12
|
+
type: Object,
|
|
13
|
+
default: () => null,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// 批量插入
|
|
17
|
+
inserts = {
|
|
18
|
+
type: Array,
|
|
19
|
+
default: () => [],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// 显示或隐藏所有所有
|
|
23
|
+
isShowAll = {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: true,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// 清除多边形以及标记
|
|
30
|
+
clear = {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// 是否根据bbox 设为中心点
|
|
36
|
+
isFit = {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: true,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
export default class MapDto {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.mapType = {
|
|
4
|
+
type: Number,
|
|
5
|
+
default: 0,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
this.layerType = {
|
|
9
|
+
type: Number,
|
|
10
|
+
default:2 ,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
this.isSwitchMapTool = {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: true,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
this.isRyMapTool = {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: false,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
this.isRight = {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: false,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
this.bindMapClick = {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
this.bindMapMoveend = {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: false,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.isDisabledSwitchMapTabEvent={
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// 初始化编辑多边形
|
|
45
|
+
this.initModifyPolygon = {
|
|
46
|
+
type: [String, Object],
|
|
47
|
+
default: () => null,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// 地图中心点计算中心点距离 默认 单位m
|
|
51
|
+
this.m = {
|
|
52
|
+
type: Number,
|
|
53
|
+
default: () => 3000,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
//切换地图的默认瓦片和类型
|
|
57
|
+
this.switchMapDefaultTypeOrLayer = {
|
|
58
|
+
type: Array,
|
|
59
|
+
default: ()=> null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//地图类型以及瓦片的数据结构
|
|
63
|
+
this.mapTypeAndLayer = {
|
|
64
|
+
type: Array,
|
|
65
|
+
default: () => [
|
|
66
|
+
{
|
|
67
|
+
id:0,
|
|
68
|
+
icon: 'el-icon--tianditu',
|
|
69
|
+
activeIcon: 'el-icon--tianditu-copy',
|
|
70
|
+
name: '天地图',
|
|
71
|
+
layer: [
|
|
72
|
+
{
|
|
73
|
+
id:0,
|
|
74
|
+
name:'地图'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id:1,
|
|
78
|
+
name:'卫星'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
id:2,
|
|
82
|
+
name:'卫星组合'
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id:1,
|
|
88
|
+
icon: 'el-icon--gaode',
|
|
89
|
+
activeIcon: 'el-icon--gaode-copy',
|
|
90
|
+
name: '高德地图',
|
|
91
|
+
layer: [
|
|
92
|
+
{
|
|
93
|
+
id:0,
|
|
94
|
+
name:'地图'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id:1,
|
|
98
|
+
name:'卫星'
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id:2,
|
|
102
|
+
name:'卫星组合'
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id:2,
|
|
108
|
+
icon: 'el-icon--Bing',
|
|
109
|
+
activeIcon: 'el-icon--Bing-copy',
|
|
110
|
+
name: 'Bing地图',
|
|
111
|
+
layer: [
|
|
112
|
+
{
|
|
113
|
+
id:1,
|
|
114
|
+
name:'卫星'
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id:2,
|
|
118
|
+
name:'卫星组合'
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
isShowSwitchMap={
|
|
126
|
+
type: Boolean,
|
|
127
|
+
default: true,
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
urls={
|
|
131
|
+
type: Array,
|
|
132
|
+
default: ()=> [],
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
boundaryModel={
|
|
136
|
+
type: Object,
|
|
137
|
+
default: ()=> null,
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
const viewOptions = {
|
|
2
|
+
projection: 'EPSG:4326',
|
|
3
|
+
center: [116.40769, 39.89945],
|
|
4
|
+
zoom: 18
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export default class MapDto {
|
|
8
|
+
constructor(opt) {
|
|
9
|
+
|
|
10
|
+
// 默认缩放率
|
|
11
|
+
this.zoom = {
|
|
12
|
+
type: Number,
|
|
13
|
+
default: 10,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// 最大缩放率
|
|
17
|
+
this.maxZoom = {
|
|
18
|
+
type: Number,
|
|
19
|
+
default: 18,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// 最小缩放率
|
|
23
|
+
this.minZoom = {
|
|
24
|
+
type: Number,
|
|
25
|
+
default: 1,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// 默认中心点数组
|
|
29
|
+
this.center = {
|
|
30
|
+
type: Array,
|
|
31
|
+
default: () => [116.40769, 39.89945],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// 投影方式
|
|
35
|
+
|
|
36
|
+
this.projection = {
|
|
37
|
+
type: String,
|
|
38
|
+
default: 'EPSG:4326',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// 二维数组 [[],[]] 根据多个中心点数组进行定位 fit 适合用于 多边形 marker 折线等
|
|
42
|
+
this.bbox = {
|
|
43
|
+
type: Array,
|
|
44
|
+
default: () => [],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// this.viewOptions = {
|
|
50
|
+
// type: Object,
|
|
51
|
+
// default: () => {
|
|
52
|
+
// return {
|
|
53
|
+
// projection: 'EPSG:4326',
|
|
54
|
+
// center: [116.40769, 39.89945],
|
|
55
|
+
// zoom: 18,
|
|
56
|
+
// minZoom:1,
|
|
57
|
+
// maxZoom:18
|
|
58
|
+
// };
|
|
59
|
+
// }
|
|
60
|
+
// }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
</template>
|
|
3
|
+
|
|
4
|
+
<script>
|
|
5
|
+
import {
|
|
6
|
+
fitNew,
|
|
7
|
+
GPS,
|
|
8
|
+
LKML,
|
|
9
|
+
} from 'ry-map';
|
|
10
|
+
import Dto from './../../models/ryKML/index.js';
|
|
11
|
+
export default {
|
|
12
|
+
name: 'RyKMLs',
|
|
13
|
+
props: {
|
|
14
|
+
...new Dto(),
|
|
15
|
+
},
|
|
16
|
+
data() {
|
|
17
|
+
return {
|
|
18
|
+
bbox: [],
|
|
19
|
+
bboxGCJ02: [],
|
|
20
|
+
kml: null,
|
|
21
|
+
lastType: -1,
|
|
22
|
+
url:null,
|
|
23
|
+
gcj02Url:null,
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
watch: {
|
|
27
|
+
model(val) {
|
|
28
|
+
this._remove();
|
|
29
|
+
if (!val.length) return;
|
|
30
|
+
this.model = val;
|
|
31
|
+
this.init(val);
|
|
32
|
+
},
|
|
33
|
+
clear(val) {
|
|
34
|
+
if (val) {
|
|
35
|
+
this._remove();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
isShow(val) {
|
|
39
|
+
if (val) {
|
|
40
|
+
this.showAll();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
this.hideAll();
|
|
44
|
+
},
|
|
45
|
+
gpsType(val) {
|
|
46
|
+
if (this.lastType == val) return;
|
|
47
|
+
this.gpsType = val;
|
|
48
|
+
this.lastType = val;
|
|
49
|
+
this.selectGPSAll(this.gpsType);
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
created() {
|
|
55
|
+
this.lastType = this.gpsType;
|
|
56
|
+
if(!this.model) return;
|
|
57
|
+
this.init(this.model);
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
methods: {
|
|
61
|
+
init(model) {
|
|
62
|
+
this._insert(model);
|
|
63
|
+
if(this.isFit){
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
this.setFit();
|
|
66
|
+
}, 50);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
},
|
|
70
|
+
_insert(dto) {
|
|
71
|
+
const {
|
|
72
|
+
id,
|
|
73
|
+
url,
|
|
74
|
+
bbox,
|
|
75
|
+
is,
|
|
76
|
+
stroke,
|
|
77
|
+
fillColor,
|
|
78
|
+
zIndex,
|
|
79
|
+
width,
|
|
80
|
+
extractStyles,
|
|
81
|
+
gcj02Url
|
|
82
|
+
} = dto;
|
|
83
|
+
const lkml = new LKML({
|
|
84
|
+
id,
|
|
85
|
+
url: this.gpsType == 1 ? gcj02Url : url,
|
|
86
|
+
bbox,
|
|
87
|
+
is,
|
|
88
|
+
stroke,
|
|
89
|
+
fillColor,
|
|
90
|
+
zIndex,
|
|
91
|
+
width,
|
|
92
|
+
},
|
|
93
|
+
this.map,
|
|
94
|
+
extractStyles);
|
|
95
|
+
this.kml=lkml;
|
|
96
|
+
this.url=url;
|
|
97
|
+
this.gcj02Url=gcj02Url;
|
|
98
|
+
this.setBBOXArr(bbox);
|
|
99
|
+
},
|
|
100
|
+
setBBOXArr(bbox) {
|
|
101
|
+
this.bbox=bbox;
|
|
102
|
+
const _bboxGCJ02 = this.convertBBoxGCJ02(bbox);
|
|
103
|
+
this.bboxGCJ02=_bboxGCJ02;
|
|
104
|
+
},
|
|
105
|
+
setUrl(url) {
|
|
106
|
+
|
|
107
|
+
if (this.kml) {
|
|
108
|
+
|
|
109
|
+
this.kml.setUrl(url);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
setFit() {
|
|
113
|
+
|
|
114
|
+
if (!this.bbox.length || !this.map) return;
|
|
115
|
+
this.setFitFist(this.gpsType == 1 ? this.bboxGCJ02 : this.bbox);
|
|
116
|
+
},
|
|
117
|
+
// bbox.length =1 执行此处
|
|
118
|
+
setFitFist(bbox) {
|
|
119
|
+
const bbox2 = [bbox[0], bbox[3], bbox[2], bbox[1]];
|
|
120
|
+
const bbox3 = [bbox[2], bbox[1], bbox[0], bbox[3]];
|
|
121
|
+
fitNew(this.map, [bbox2, bbox3]);
|
|
122
|
+
},
|
|
123
|
+
convertBBoxGCJ02(bbox) {
|
|
124
|
+
const pointArr = [];
|
|
125
|
+
const {
|
|
126
|
+
lat,
|
|
127
|
+
lon
|
|
128
|
+
} = GPS.gcj_encrypt(bbox[0], bbox[1]);
|
|
129
|
+
const {
|
|
130
|
+
lon: lon2,
|
|
131
|
+
lat: lat2
|
|
132
|
+
} = GPS.gcj_encrypt(bbox[2], bbox[3]);
|
|
133
|
+
pointArr.push(lon);
|
|
134
|
+
pointArr.push(lat);
|
|
135
|
+
pointArr.push(lon2);
|
|
136
|
+
pointArr.push(lat2);
|
|
137
|
+
return pointArr;
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
_remove() {
|
|
141
|
+
if(!this.kml) return;
|
|
142
|
+
this.kml.removeKML();
|
|
143
|
+
this.bbox = [];
|
|
144
|
+
this.bboxGCJ02 = [];
|
|
145
|
+
this.url=null;
|
|
146
|
+
this.gcj02Url=null;
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
selectGPSAll(type) {
|
|
150
|
+
const url = type == 1 ? this.gcj02Url : this.url;
|
|
151
|
+
this.setUrl(url);
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
show() {
|
|
155
|
+
if(!this.kml) return;
|
|
156
|
+
this.kml.show();
|
|
157
|
+
if(this.isFit){
|
|
158
|
+
setTimeout(() => {
|
|
159
|
+
this.setFit();
|
|
160
|
+
}, 50);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
hide() {
|
|
165
|
+
if(!this.kml) return;
|
|
166
|
+
this.kml.hide();
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
},
|
|
170
|
+
}
|
|
171
|
+
</script>
|
|
172
|
+
|
|
173
|
+
<style>
|
|
174
|
+
</style>
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
</template>
|
|
3
|
+
|
|
4
|
+
<script>
|
|
5
|
+
import {
|
|
6
|
+
fitNew,
|
|
7
|
+
GPS,
|
|
8
|
+
LKML,
|
|
9
|
+
} from 'ry-map';
|
|
10
|
+
import Dto from './../../models/ryKMLs/index.js';
|
|
11
|
+
export default {
|
|
12
|
+
name: 'RyKMLs',
|
|
13
|
+
props: {
|
|
14
|
+
...new Dto(),
|
|
15
|
+
},
|
|
16
|
+
data() {
|
|
17
|
+
return {
|
|
18
|
+
bbox: [],
|
|
19
|
+
bboxMap: new Map(),
|
|
20
|
+
bboxGCJ02: [],
|
|
21
|
+
bboxMapGCJ02: new Map(),
|
|
22
|
+
kmlMap: new Map(),
|
|
23
|
+
isCreate: true,
|
|
24
|
+
lastType: -1,
|
|
25
|
+
urls: new Map(),
|
|
26
|
+
gcj02Urls: new Map(),
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
watch: {
|
|
30
|
+
modelArr(val) {
|
|
31
|
+
this._remove();
|
|
32
|
+
if (!val.length) return;
|
|
33
|
+
this.modelArr = val;
|
|
34
|
+
this.init(val);
|
|
35
|
+
},
|
|
36
|
+
gpsType(val) {
|
|
37
|
+
if (this.lastType == val) return;
|
|
38
|
+
this.gpsType = val;
|
|
39
|
+
this.lastType = val;
|
|
40
|
+
this.selectGPSAll(this.gpsType);
|
|
41
|
+
},
|
|
42
|
+
insert(val) {
|
|
43
|
+
this.insert = val;
|
|
44
|
+
this._insert(val);
|
|
45
|
+
if(this.isFit){
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
this.setFit();
|
|
48
|
+
}, 50);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
inserts(val) {
|
|
52
|
+
this.inserts = val;
|
|
53
|
+
this._inserts(val);
|
|
54
|
+
},
|
|
55
|
+
clear(val) {
|
|
56
|
+
if (val) {
|
|
57
|
+
this._remove();
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
isShowAll(val) {
|
|
61
|
+
if (val) {
|
|
62
|
+
this.showAll();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.hideAll();
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
created() {
|
|
71
|
+
this.lastType = this.gpsType;
|
|
72
|
+
this.init(this.modelArr);
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
methods: {
|
|
76
|
+
init(arr) {
|
|
77
|
+
// this._insert();
|
|
78
|
+
if (!arr || !arr.length) return;
|
|
79
|
+
arr.forEach(val => {
|
|
80
|
+
this._insert(val);
|
|
81
|
+
});
|
|
82
|
+
if(this.isFit){
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
this.setFit();
|
|
85
|
+
}, 50);
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
_inserts(arr) {
|
|
89
|
+
this.lastType = this.gpsType;
|
|
90
|
+
arr.forEach(val => {
|
|
91
|
+
this._insert(val, false);
|
|
92
|
+
});
|
|
93
|
+
if(this.isFit){
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
this.setFit();
|
|
96
|
+
}, 50);
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
_insert(dto) {
|
|
100
|
+
const {
|
|
101
|
+
id,
|
|
102
|
+
url,
|
|
103
|
+
bbox,
|
|
104
|
+
is,
|
|
105
|
+
stroke,
|
|
106
|
+
fillColor,
|
|
107
|
+
zIndex,
|
|
108
|
+
width,
|
|
109
|
+
extractStyles,
|
|
110
|
+
gcj02Url
|
|
111
|
+
} = dto;
|
|
112
|
+
if (!this.kmlMap.has(id)) {
|
|
113
|
+
const lkml = new LKML({
|
|
114
|
+
id,
|
|
115
|
+
url: this.gpsType == 1 ? gcj02Url : url,
|
|
116
|
+
bbox,
|
|
117
|
+
is,
|
|
118
|
+
stroke,
|
|
119
|
+
fillColor,
|
|
120
|
+
zIndex,
|
|
121
|
+
width,
|
|
122
|
+
},
|
|
123
|
+
this.map,
|
|
124
|
+
extractStyles);
|
|
125
|
+
this.kmlMap.set(id, lkml);
|
|
126
|
+
this.urls.set(id, url);
|
|
127
|
+
if (gcj02Url) {
|
|
128
|
+
this.gcj02Urls.set(id, gcj02Url);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
this.setBBOXArr(dto.id, bbox);
|
|
132
|
+
},
|
|
133
|
+
setBBOXArr(id, bbox) {
|
|
134
|
+
if (!this.bboxMap.has(id)) {
|
|
135
|
+
this.bbox.push(bbox);
|
|
136
|
+
this.bboxMap.set(id, bbox);
|
|
137
|
+
}
|
|
138
|
+
if (!this.bboxMapGCJ02.has(id)) {
|
|
139
|
+
const _bboxGCJ02 = this.convertBBoxGCJ02(bbox);
|
|
140
|
+
this.bboxGCJ02.push(_bboxGCJ02);
|
|
141
|
+
this.bboxMapGCJ02.set(id, _bboxGCJ02);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
setUrl(id, url) {
|
|
145
|
+
if (this.kmlMap.has(id)) {
|
|
146
|
+
this.kmlMap.get(id).setUrl(url);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
setFit() {
|
|
150
|
+
if (!this.bbox.length || !this.map) return;
|
|
151
|
+
if (this.bbox.length > 1) {
|
|
152
|
+
fitNew(this.map, this.gpsType == 1 ? this.bboxGCJ02 : this.bbox);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
this.setFitFist(this.gpsType == 1 ? this.bboxGCJ02[0] : this.bbox[0]);
|
|
156
|
+
},
|
|
157
|
+
// bbox.length =1 执行此处
|
|
158
|
+
setFitFist(bbox) {
|
|
159
|
+
const bbox2 = [bbox[0], bbox[3], bbox[2], bbox[1]];
|
|
160
|
+
const bbox3 = [bbox[2], bbox[1], bbox[0], bbox[3]];
|
|
161
|
+
fitNew(this.map, [bbox2, bbox3]);
|
|
162
|
+
},
|
|
163
|
+
convertBBoxGCJ02(bbox) {
|
|
164
|
+
const pointArr = [];
|
|
165
|
+
const {
|
|
166
|
+
lat,
|
|
167
|
+
lon
|
|
168
|
+
} = GPS.gcj_encrypt(bbox[0], bbox[1]);
|
|
169
|
+
const {
|
|
170
|
+
lon: lon2,
|
|
171
|
+
lat: lat2
|
|
172
|
+
} = GPS.gcj_encrypt(bbox[2], bbox[3]);
|
|
173
|
+
pointArr.push(lon);
|
|
174
|
+
pointArr.push(lat);
|
|
175
|
+
pointArr.push(lon2);
|
|
176
|
+
pointArr.push(lat2);
|
|
177
|
+
return pointArr;
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
_remove() {
|
|
181
|
+
this.kmlMap.forEach(val => {
|
|
182
|
+
val.removeKML();
|
|
183
|
+
val = null;
|
|
184
|
+
});
|
|
185
|
+
this.kmlMap.clear();
|
|
186
|
+
this.bboxMap.clear();
|
|
187
|
+
this.bbox = [];
|
|
188
|
+
this.bboxGCJ02 = [];
|
|
189
|
+
this.bboxMapGCJ02.clear();
|
|
190
|
+
this.urls.clear();
|
|
191
|
+
this.gcj02Urls.clear();
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
selectGPSAll(type) {
|
|
195
|
+
const arrs = type == 1 ? this.gcj02Urls : this.urls;
|
|
196
|
+
arrs.forEach((url, key) => {
|
|
197
|
+
this.setUrl(key, url);
|
|
198
|
+
});
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
showAll() {
|
|
202
|
+
this.kmlMap.forEach(val => val.show());
|
|
203
|
+
if (this.restFit) {
|
|
204
|
+
this._restFit();
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
hideAll() {
|
|
209
|
+
this.kmlMap.forEach(val => val.hide());
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
},
|
|
213
|
+
}
|
|
214
|
+
</script>
|
|
215
|
+
|
|
216
|
+
<style>
|
|
217
|
+
</style>
|