ry-vue-map 0.2.0 → 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 +467 -287
- package/lib/ryui.common.js.gz +0 -0
- package/lib/ryui.css +1 -1
- package/lib/ryui.umd.js +467 -287
- 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/components/maps/ryVectorMap/src/index.vue +4 -4
- 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
|
@@ -1,944 +1,967 @@
|
|
|
1
|
-
|
|
2
1
|
import 'ol/ol.css';
|
|
3
2
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
3
|
+
AM,
|
|
4
|
+
BingMapsServices,
|
|
5
|
+
BingMapsServiceNew,
|
|
6
|
+
CheckPoint,
|
|
7
|
+
DraftingEvent,
|
|
8
|
+
SvgModel,
|
|
9
|
+
geo2svg,
|
|
10
|
+
GPS,
|
|
11
|
+
GrahamScan,
|
|
12
|
+
LMap,
|
|
13
|
+
MapConfig,
|
|
14
|
+
formatArea,
|
|
15
|
+
formatLength,
|
|
16
|
+
createSpan,
|
|
17
|
+
getVector,
|
|
18
|
+
addInteraction,
|
|
19
|
+
addInteraction1,
|
|
20
|
+
getCoordinates,
|
|
21
|
+
createGeoJson,
|
|
22
|
+
getLngAndLatMaxMin,
|
|
23
|
+
rayCasting,
|
|
24
|
+
createPolygonGeojson,
|
|
25
|
+
zoomIn,
|
|
26
|
+
zoomOut,
|
|
27
|
+
getCenterPoint,
|
|
28
|
+
createGPSPoints,
|
|
29
|
+
createPolylinePoints,
|
|
30
|
+
fitNew,
|
|
31
|
+
createRectangle,
|
|
32
|
+
getColorStyle,
|
|
33
|
+
createFill,
|
|
34
|
+
polygonStyle,
|
|
35
|
+
getLayer,
|
|
36
|
+
getLayerNew,
|
|
37
|
+
flyTo,
|
|
38
|
+
tour,
|
|
39
|
+
PolygonModel,
|
|
40
|
+
createPolygonBoundary,
|
|
41
|
+
caculateLL,
|
|
42
|
+
LMarker,
|
|
43
|
+
LModifyEvent,
|
|
44
|
+
LOverlay,
|
|
45
|
+
Polyline,
|
|
46
|
+
addPolylinePoint,
|
|
47
|
+
addPolylinePointNew,
|
|
48
|
+
getDeepColorNew,
|
|
49
|
+
LPolygonNew,
|
|
50
|
+
Circular,
|
|
51
|
+
LCluster,
|
|
52
|
+
HelpTooltip,
|
|
53
|
+
pathToLines,
|
|
54
|
+
isTruePolygon,
|
|
55
|
+
CrossHair,
|
|
56
|
+
LDraw,
|
|
57
|
+
FeaturePolygon,
|
|
58
|
+
FeaturePolygonModel,
|
|
59
|
+
LMarkerFont,
|
|
60
|
+
LMessage,
|
|
61
|
+
LPolygon,
|
|
62
|
+
calculateCenter,
|
|
63
|
+
MeasureTooltip,
|
|
64
|
+
staticImage,
|
|
65
|
+
TMapOptions,
|
|
66
|
+
LCircle,
|
|
67
|
+
ViewOptions,
|
|
68
|
+
MapTypeEnum,
|
|
69
|
+
MapLayersEnum,
|
|
70
|
+
BingLayers,
|
|
71
|
+
BDLayers,
|
|
72
|
+
LRectangle,
|
|
73
|
+
VectorMap
|
|
75
74
|
} from 'ry-map';
|
|
76
75
|
|
|
76
|
+
import {
|
|
77
|
+
defaults as interactionDefaults
|
|
78
|
+
} from 'ol/interaction';
|
|
79
|
+
|
|
77
80
|
export default class LMapServices {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
81
|
+
constructor() {
|
|
82
|
+
this.map = null;
|
|
83
|
+
this._lPolygon = null;
|
|
84
|
+
this._measureTooltip = null;
|
|
85
|
+
this.currentLayer = [false, false, true];
|
|
86
|
+
this.polygonGeojsonArr = [];
|
|
87
|
+
this.polygonGeojson = null;
|
|
88
|
+
this.lModifyEventArr = [];
|
|
89
|
+
this.lmap = null;
|
|
90
|
+
this.lMEvent = null;
|
|
91
|
+
this.am = new AM();
|
|
92
|
+
this.type = 2;
|
|
93
|
+
this.lPolygonNewArr = new Array();
|
|
94
|
+
this.polygonGeojsonMap = new Map();
|
|
95
|
+
this.drawPolygonArr = new Set();
|
|
96
|
+
this.drawLineArr = new Set();
|
|
97
|
+
this._lRectangle = null;
|
|
98
|
+
this.layers = null;
|
|
99
|
+
}
|
|
100
|
+
init(optins) {
|
|
101
|
+
const {
|
|
102
|
+
el,
|
|
103
|
+
type,
|
|
104
|
+
callback,
|
|
105
|
+
viewOptions,
|
|
106
|
+
layerType,
|
|
107
|
+
mapType
|
|
108
|
+
} = optins;
|
|
109
|
+
|
|
110
|
+
this.initMap({
|
|
111
|
+
el,
|
|
112
|
+
callback,
|
|
113
|
+
viewOptions,
|
|
114
|
+
type,
|
|
115
|
+
layerType
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
initMap({
|
|
119
|
+
el,
|
|
120
|
+
callback,
|
|
121
|
+
type,
|
|
122
|
+
viewOptions,
|
|
123
|
+
layerType
|
|
124
|
+
}) {
|
|
125
|
+
if (!this.lmap) {
|
|
126
|
+
this.lmap = new LMap({
|
|
127
|
+
controls: MapConfig.Defaults,
|
|
128
|
+
interactions: interactionDefaults({
|
|
129
|
+
pinchRotate: false,
|
|
130
|
+
})
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
setTimeout(() => {
|
|
134
|
+
const _async = async () => {
|
|
135
|
+
if (this.map) {
|
|
136
|
+
this.map = null;
|
|
137
|
+
}
|
|
138
|
+
const {
|
|
139
|
+
map,
|
|
140
|
+
layers
|
|
141
|
+
} = await this.lmap.onLoad(el, type, layerType);
|
|
142
|
+
this.map = map;
|
|
143
|
+
this.layers = layers;
|
|
144
|
+
MapConfig.View = viewOptions;
|
|
145
|
+
this.map.setView(MapConfig.View);
|
|
146
|
+
if (callback) {
|
|
147
|
+
callback(this.map, layers);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
_async();
|
|
151
|
+
}, 100);
|
|
152
|
+
}
|
|
153
|
+
get getMapTypeLength() {
|
|
154
|
+
return this.lmap.getMapTypeLength;
|
|
155
|
+
}
|
|
156
|
+
get getLayeTypeLength() {
|
|
157
|
+
return this.lmap.getLayeTypeLength;
|
|
158
|
+
}
|
|
159
|
+
selectMapLayer(mapType, layerType) {
|
|
160
|
+
if (!this.lmap) return 0;
|
|
161
|
+
return this.lmap.selectLayers(mapType, layerType);
|
|
162
|
+
}
|
|
163
|
+
initBingMap(el, callback, viewOptions) {
|
|
164
|
+
// this.clear();
|
|
165
|
+
if (!this.lmap) {
|
|
166
|
+
this.lmap = new LMap({
|
|
167
|
+
controls: MapConfig.Defaults,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
setTimeout(() => {
|
|
172
|
+
const _async = async () => {
|
|
173
|
+
if (this.map) {
|
|
174
|
+
this.map = null;
|
|
175
|
+
}
|
|
176
|
+
const {
|
|
177
|
+
map,
|
|
178
|
+
layers
|
|
179
|
+
} = await this.lmap.onLoad(el, 2, 2);
|
|
180
|
+
this.map = map;
|
|
181
|
+
this.layers = layers;
|
|
182
|
+
MapConfig.View = viewOptions;
|
|
183
|
+
this.map.setView(MapConfig.View);
|
|
184
|
+
if (callback) {
|
|
185
|
+
callback(this.map, layers);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
_async();
|
|
189
|
+
}, 100);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
initBingMapNew(el, callback, viewOptions) {
|
|
193
|
+
|
|
194
|
+
if (!this.lmap) {
|
|
195
|
+
this.lmap = new LMap({
|
|
196
|
+
controls: MapConfig.Defaults,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
setTimeout(() => {
|
|
201
|
+
const _async = async () => {
|
|
202
|
+
if (this.map) {
|
|
203
|
+
this.map = null;
|
|
204
|
+
}
|
|
205
|
+
const {
|
|
206
|
+
map,
|
|
207
|
+
layers
|
|
208
|
+
} = await this.lmap.onLoad(el, 0, 2);
|
|
209
|
+
this.map = map;
|
|
210
|
+
this.layers = layers;
|
|
211
|
+
MapConfig.View = viewOptions;
|
|
212
|
+
this.map.setView(MapConfig.View);
|
|
213
|
+
if (callback) {
|
|
214
|
+
callback(this.map, layers);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
_async();
|
|
218
|
+
}, 100);
|
|
219
|
+
|
|
220
|
+
// if (!this.lmap) {
|
|
221
|
+
// this.lmap = new LMap({
|
|
222
|
+
// controls: MapConfig.Defaults,
|
|
223
|
+
// });
|
|
224
|
+
// }
|
|
225
|
+
|
|
226
|
+
// setTimeout(() => {
|
|
227
|
+
// const _async = async () => {
|
|
228
|
+
// if (this.map) {
|
|
229
|
+
// this.map = null;
|
|
230
|
+
// }
|
|
231
|
+
// this.map = await this.lmap.onLoad(el,3,1);
|
|
232
|
+
// MapConfig.View = viewOptions;
|
|
233
|
+
// this.map.setView(MapConfig.View);
|
|
234
|
+
// if (callback) {
|
|
235
|
+
// callback(this.map);
|
|
236
|
+
// }
|
|
237
|
+
// };
|
|
238
|
+
// _async();
|
|
239
|
+
// }, 100);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async initVectorMap(opt) {
|
|
243
|
+
const {
|
|
244
|
+
el,
|
|
245
|
+
isAnalysisBBOX,
|
|
246
|
+
isAnalysisCenter,
|
|
247
|
+
callback,
|
|
248
|
+
delaytime,
|
|
249
|
+
isDrag
|
|
250
|
+
} = opt;
|
|
251
|
+
const vmap = new VectorMap({
|
|
252
|
+
isAnalysisBBOX,
|
|
253
|
+
isAnalysisCenter,
|
|
254
|
+
isDrag,
|
|
255
|
+
callback: r => {
|
|
256
|
+
if (callback) {
|
|
257
|
+
callback(r);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
return new Promise(r => {
|
|
263
|
+
setTimeout(async () => {
|
|
264
|
+
const map = await vmap.onLoad(el);
|
|
265
|
+
r({
|
|
266
|
+
map,
|
|
267
|
+
vmap
|
|
268
|
+
});
|
|
269
|
+
}, delaytime ? delaytime : 100);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
getVectorLayerView() {
|
|
275
|
+
return MapConfig.getVectorLayerView;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
onSetLayers(type) {
|
|
279
|
+
this.type = type;
|
|
280
|
+
this.currentLayer = this.currentLayer.map((r) => (r = false));
|
|
281
|
+
this.currentLayer[type] = true;
|
|
282
|
+
this.removeLayers(type);
|
|
283
|
+
this.addLayers(type);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
removeLayers(type) {
|
|
287
|
+
MapConfig.TMapLayerArr[type].forEach((val, key) => {
|
|
288
|
+
this.map.removeLayer(val);
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
addLayers(type) {
|
|
293
|
+
MapConfig.TMapLayerArr[type].forEach((val, key) => {
|
|
294
|
+
this.map.addLayer(val);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
onCreatePolygon(callback, type) {
|
|
299
|
+
if (this.polygonGeojson) {
|
|
300
|
+
this.map.removeLayer(this.polygonGeojson);
|
|
301
|
+
}
|
|
302
|
+
if (this._lPolygon) {
|
|
303
|
+
this.clearlPolygon();
|
|
304
|
+
// this._removeMeasureTooltip();
|
|
305
|
+
}
|
|
306
|
+
const _this = this;
|
|
307
|
+
this._lPolygon = new LPolygon(this.map, {
|
|
308
|
+
strokeColor: 'rgba(255,201,14, 1)',
|
|
309
|
+
fillColor: 'rgba(255,201,14, 0.4)',
|
|
310
|
+
type
|
|
311
|
+
});
|
|
312
|
+
return this._lPolygon;
|
|
313
|
+
// if (callback) {
|
|
314
|
+
// callback();
|
|
315
|
+
// }
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
skipCurrentDraw() {
|
|
319
|
+
if (this._lPolygon) {
|
|
320
|
+
this._lPolygon.skipCurrentDraw();
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
onCancel() {
|
|
325
|
+
if (this._lPolygon) {
|
|
326
|
+
this._lPolygon.removeLastPoint();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
onDelete(callback) {
|
|
331
|
+
if (this._lPolygon) {
|
|
332
|
+
this._lPolygon.remove();
|
|
333
|
+
this._lPolygon = null;
|
|
334
|
+
this._removeMeasureTooltip();
|
|
335
|
+
if (callback) {
|
|
336
|
+
callback();
|
|
337
|
+
}
|
|
338
|
+
} else {}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
getGeoJson() {
|
|
342
|
+
if (this._lPolygon) {
|
|
343
|
+
const [x, y] = this._lPolygon.getCenterPoint();
|
|
344
|
+
const geojson = createGeoJson(this._lPolygon.getCoordinates(), {
|
|
345
|
+
ruleId: '',
|
|
346
|
+
centerlon: x,
|
|
347
|
+
centerlat: y
|
|
348
|
+
});
|
|
349
|
+
return geojson;
|
|
350
|
+
}
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
getGeoJsonNew(index) {
|
|
355
|
+
if (this.polygonGeojson) {
|
|
356
|
+
const polygon = this.polygonGeojson;
|
|
357
|
+
const geojson = createGeoJson(
|
|
358
|
+
polygon.getSource().getFeatures()[0].getGeometry().getCoordinates(), {
|
|
359
|
+
ruleId: '',
|
|
360
|
+
centerlon: 0,
|
|
361
|
+
centerlat: 0
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
return geojson;
|
|
365
|
+
}
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
getPolygonGeoJson() {
|
|
370
|
+
if (!this._lPolygon) return null;
|
|
371
|
+
return this._lPolygon.getGeoJson();
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
onCreateLine() {
|
|
375
|
+
if (this.map) {
|
|
376
|
+
let drawLine = new LDraw(
|
|
377
|
+
'LineString',
|
|
378
|
+
(e) => {
|
|
379
|
+
// let arrs = e.feature.getGeometry().getCoordinates();
|
|
380
|
+
// let tooltipCoord = e.coordinate;
|
|
381
|
+
// const obj = {
|
|
382
|
+
// pointArr: arrs,
|
|
383
|
+
// color: '#000',
|
|
384
|
+
// width: 2
|
|
385
|
+
// };
|
|
386
|
+
// new Polyline(obj, this.map);
|
|
387
|
+
},
|
|
388
|
+
this.map
|
|
389
|
+
);
|
|
390
|
+
this.drawLineArr.add(drawLine);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
onCreateArea() {
|
|
395
|
+
if (this.map) {
|
|
396
|
+
this.drawPolygonArr.add(new LDraw('Polygon', (e) => {}, this.map));
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
removeDrawArr() {
|
|
401
|
+
|
|
402
|
+
this.drawLineArr.forEach(val => {
|
|
403
|
+
if (val) {
|
|
404
|
+
try {
|
|
405
|
+
val.clear();
|
|
406
|
+
} catch (err) {
|
|
407
|
+
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
this.drawLineArr.clear();
|
|
413
|
+
|
|
414
|
+
this.drawPolygonArr.forEach(val => {
|
|
415
|
+
if (val) {
|
|
416
|
+
try {
|
|
417
|
+
val.clear();
|
|
418
|
+
} catch (err) {
|
|
419
|
+
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
this.drawPolygonArr.clear();
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
clearlPolygon() {
|
|
429
|
+
if (this.map && this._lPolygon) {
|
|
430
|
+
this._lPolygon.remove();
|
|
431
|
+
this._lPolygon = null;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
_createMeasureTooltip() {
|
|
436
|
+
const marker = new MeasureTooltip();
|
|
437
|
+
marker.setOffset([0, -30]);
|
|
438
|
+
this._measureTooltip = marker;
|
|
439
|
+
return marker;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
_removeMeasureTooltip() {
|
|
443
|
+
if (this.map) {
|
|
444
|
+
if (this._measureTooltip) {
|
|
445
|
+
this.map.removeOverlay(this._measureTooltip.getMarker());
|
|
298
446
|
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
createPolygonGeojson(
|
|
451
|
+
geoJsonObj,
|
|
452
|
+
fillColor = 'rgba(255, 255, 255, 0.3)',
|
|
453
|
+
stroke = 'rgba(00, 131, 241, 1)',
|
|
454
|
+
id,
|
|
455
|
+
isSetId = false,
|
|
456
|
+
lineDash = []
|
|
457
|
+
) {
|
|
458
|
+
if (this.map) {
|
|
459
|
+
const polygonGeojson = createPolygonGeojson(
|
|
460
|
+
geoJsonObj,
|
|
461
|
+
fillColor,
|
|
462
|
+
stroke,
|
|
463
|
+
id,
|
|
464
|
+
isSetId,
|
|
465
|
+
lineDash
|
|
466
|
+
);
|
|
467
|
+
this.polygonGeojsonArr.push(polygonGeojson);
|
|
468
|
+
this.polygonGeojson = null;
|
|
469
|
+
this.map.addLayer(polygonGeojson);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
createPolygonGeojsonNew(
|
|
474
|
+
geoJsonObj,
|
|
475
|
+
fillColor = 'rgba(255, 255, 255, 0.3)',
|
|
476
|
+
stroke = 'rgba(00, 131, 241, 1)',
|
|
477
|
+
id,
|
|
478
|
+
isSetId = false
|
|
479
|
+
) {
|
|
480
|
+
if (this.polygonGeojson) {
|
|
481
|
+
this.polygonGeojson = null;
|
|
482
|
+
}
|
|
483
|
+
if (this.map) {
|
|
484
|
+
const polygonGeojson = createPolygonGeojson(
|
|
485
|
+
geoJsonObj,
|
|
486
|
+
fillColor,
|
|
487
|
+
stroke,
|
|
488
|
+
id,
|
|
489
|
+
isSetId
|
|
490
|
+
);
|
|
491
|
+
// this.polygonGeojsonArr.push(polygonGeojson);
|
|
492
|
+
this.polygonGeojson = polygonGeojson;
|
|
493
|
+
this.map.addLayer(polygonGeojson);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
removePolygonGeojsons() {
|
|
498
|
+
if (!this.polygonGeojsonArr.length) {
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
let item = null;
|
|
502
|
+
while ((item = this.polygonGeojsonArr.shift())) {
|
|
503
|
+
this.map.removeLayer(item);
|
|
504
|
+
item = null;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
removePolygonGeojsonNew() {
|
|
509
|
+
if (!this.polygonGeojson) {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
this.map.removeLayer(this.polygonGeojson);
|
|
513
|
+
this.polygonGeojson = null;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
clear() {
|
|
517
|
+
if (!this.map) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
if (this.am) {
|
|
521
|
+
this.am = null;
|
|
522
|
+
this.am = new AM();
|
|
523
|
+
}
|
|
524
|
+
this.removeOverlays();
|
|
525
|
+
this.removeLModifyEventArr();
|
|
526
|
+
this.removePolygonGeojsons();
|
|
527
|
+
this.clearlPolygon();
|
|
528
|
+
this.removeLModifyEvent();
|
|
529
|
+
this.removePolygonGeojsonNew();
|
|
530
|
+
this.removeMapsLayers();
|
|
531
|
+
}
|
|
532
|
+
clearNew() {
|
|
533
|
+
this.removeOverlays();
|
|
534
|
+
this.removeLModifyEventArr();
|
|
535
|
+
this.removePolygonGeojsons();
|
|
536
|
+
this.clearlPolygon();
|
|
537
|
+
this.removeLModifyEvent();
|
|
538
|
+
this.removePolygonGeojsonNew();
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
getMap() {
|
|
542
|
+
return this.map;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
setCenter([x, y], zoom) {
|
|
546
|
+
if (!this.map) {
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
const view = this.map.getView();
|
|
550
|
+
view.setCenter([x, y]);
|
|
551
|
+
if (zoom > 0) {
|
|
552
|
+
view.setZoom(zoom);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
setZoom(zoom) {
|
|
557
|
+
if (!this.map) {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
const view = this.map.getView();
|
|
561
|
+
view.setZoom(zoom);
|
|
299
562
|
}
|
|
300
563
|
|
|
301
|
-
|
|
302
|
-
if (this._lPolygon) {
|
|
303
|
-
this._lPolygon.removeLastPoint();
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
onDelete(callback) {
|
|
308
|
-
if (this._lPolygon) {
|
|
309
|
-
this._lPolygon.remove();
|
|
310
|
-
this._lPolygon = null;
|
|
311
|
-
this._removeMeasureTooltip();
|
|
312
|
-
if (callback) {
|
|
313
|
-
callback();
|
|
314
|
-
}
|
|
315
|
-
} else {}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
getGeoJson() {
|
|
319
|
-
if (this._lPolygon) {
|
|
320
|
-
const [x, y] = this._lPolygon.getCenterPoint();
|
|
321
|
-
const geojson = createGeoJson(this._lPolygon.getCoordinates(), {
|
|
322
|
-
ruleId: '',
|
|
323
|
-
centerlon: x,
|
|
324
|
-
centerlat: y
|
|
325
|
-
});
|
|
326
|
-
return geojson;
|
|
327
|
-
}
|
|
328
|
-
return null;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
getGeoJsonNew(index) {
|
|
332
|
-
if (this.polygonGeojson) {
|
|
333
|
-
const polygon = this.polygonGeojson;
|
|
334
|
-
const geojson = createGeoJson(
|
|
335
|
-
polygon.getSource().getFeatures()[0].getGeometry().getCoordinates(), {
|
|
336
|
-
ruleId: '',
|
|
337
|
-
centerlon: 0,
|
|
338
|
-
centerlat: 0
|
|
339
|
-
}
|
|
340
|
-
);
|
|
341
|
-
return geojson;
|
|
342
|
-
}
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
getPolygonGeoJson() {
|
|
347
|
-
if (!this._lPolygon) return null;
|
|
348
|
-
return this._lPolygon.getGeoJson();
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
onCreateLine() {
|
|
352
|
-
if (this.map) {
|
|
353
|
-
let drawLine = new LDraw(
|
|
354
|
-
'LineString',
|
|
355
|
-
(e) => {
|
|
356
|
-
// let arrs = e.feature.getGeometry().getCoordinates();
|
|
357
|
-
// let tooltipCoord = e.coordinate;
|
|
358
|
-
// const obj = {
|
|
359
|
-
// pointArr: arrs,
|
|
360
|
-
// color: '#000',
|
|
361
|
-
// width: 2
|
|
362
|
-
// };
|
|
363
|
-
// new Polyline(obj, this.map);
|
|
364
|
-
},
|
|
365
|
-
this.map
|
|
366
|
-
);
|
|
367
|
-
this.drawLineArr.add(drawLine);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
onCreateArea() {
|
|
372
|
-
if (this.map) {
|
|
373
|
-
this.drawPolygonArr.add(new LDraw('Polygon', (e) => {}, this.map));
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
removeDrawArr(){
|
|
378
|
-
|
|
379
|
-
this.drawLineArr.forEach(val => {
|
|
380
|
-
if(val){
|
|
381
|
-
try{
|
|
382
|
-
val.clear();
|
|
383
|
-
}catch(err){
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
this.drawLineArr.clear();
|
|
390
|
-
|
|
391
|
-
this.drawPolygonArr.forEach(val => {
|
|
392
|
-
if(val){
|
|
393
|
-
try{
|
|
394
|
-
val.clear();
|
|
395
|
-
}catch(err){
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
|
|
401
|
-
this.drawPolygonArr.clear();
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
clearlPolygon() {
|
|
406
|
-
if (this.map && this._lPolygon) {
|
|
407
|
-
this._lPolygon.remove();
|
|
408
|
-
this._lPolygon = null;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
_createMeasureTooltip() {
|
|
413
|
-
const marker = new MeasureTooltip();
|
|
414
|
-
marker.setOffset([0, -30]);
|
|
415
|
-
this._measureTooltip = marker;
|
|
416
|
-
return marker;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
_removeMeasureTooltip() {
|
|
420
|
-
if (this.map) {
|
|
421
|
-
if (this._measureTooltip) {
|
|
422
|
-
this.map.removeOverlay(this._measureTooltip.getMarker());
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
createPolygonGeojson(
|
|
428
|
-
geoJsonObj,
|
|
429
|
-
fillColor = 'rgba(255, 255, 255, 0.3)',
|
|
430
|
-
stroke = 'rgba(00, 131, 241, 1)',
|
|
431
|
-
id,
|
|
432
|
-
isSetId = false,
|
|
433
|
-
lineDash = []
|
|
434
|
-
) {
|
|
435
|
-
if (this.map) {
|
|
436
|
-
const polygonGeojson = createPolygonGeojson(
|
|
437
|
-
geoJsonObj,
|
|
438
|
-
fillColor,
|
|
439
|
-
stroke,
|
|
440
|
-
id,
|
|
441
|
-
isSetId,
|
|
442
|
-
lineDash
|
|
443
|
-
);
|
|
444
|
-
this.polygonGeojsonArr.push(polygonGeojson);
|
|
445
|
-
this.polygonGeojson = null;
|
|
446
|
-
this.map.addLayer(polygonGeojson);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
createPolygonGeojsonNew(
|
|
451
|
-
geoJsonObj,
|
|
452
|
-
fillColor = 'rgba(255, 255, 255, 0.3)',
|
|
453
|
-
stroke = 'rgba(00, 131, 241, 1)',
|
|
454
|
-
id,
|
|
455
|
-
isSetId = false
|
|
456
|
-
) {
|
|
457
|
-
if (this.polygonGeojson) {
|
|
458
|
-
this.polygonGeojson = null;
|
|
459
|
-
}
|
|
460
|
-
if (this.map) {
|
|
461
|
-
const polygonGeojson = createPolygonGeojson(
|
|
462
|
-
geoJsonObj,
|
|
463
|
-
fillColor,
|
|
464
|
-
stroke,
|
|
465
|
-
id,
|
|
466
|
-
isSetId
|
|
467
|
-
);
|
|
468
|
-
// this.polygonGeojsonArr.push(polygonGeojson);
|
|
469
|
-
this.polygonGeojson = polygonGeojson;
|
|
470
|
-
this.map.addLayer(polygonGeojson);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
removePolygonGeojsons() {
|
|
475
|
-
if (!this.polygonGeojsonArr.length) {
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
let item = null;
|
|
479
|
-
while ((item = this.polygonGeojsonArr.shift())) {
|
|
480
|
-
this.map.removeLayer(item);
|
|
481
|
-
item = null;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
removePolygonGeojsonNew() {
|
|
486
|
-
if (!this.polygonGeojson) {
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
this.map.removeLayer(this.polygonGeojson);
|
|
490
|
-
this.polygonGeojson = null;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
clear() {
|
|
494
|
-
if (!this.map) {
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
if (this.am) {
|
|
498
|
-
this.am = null;
|
|
499
|
-
this.am = new AM();
|
|
500
|
-
}
|
|
501
|
-
this.removeOverlays();
|
|
502
|
-
this.removeLModifyEventArr();
|
|
503
|
-
this.removePolygonGeojsons();
|
|
504
|
-
this.clearlPolygon();
|
|
505
|
-
this.removeLModifyEvent();
|
|
506
|
-
this.removePolygonGeojsonNew();
|
|
507
|
-
this.removeMapsLayers();
|
|
508
|
-
}
|
|
509
|
-
clearNew() {
|
|
510
|
-
this.removeOverlays();
|
|
511
|
-
this.removeLModifyEventArr();
|
|
512
|
-
this.removePolygonGeojsons();
|
|
513
|
-
this.clearlPolygon();
|
|
514
|
-
this.removeLModifyEvent();
|
|
515
|
-
this.removePolygonGeojsonNew();
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
getMap() {
|
|
519
|
-
return this.map;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
setCenter([x, y], zoom) {
|
|
523
|
-
if (!this.map) {
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
const view = this.map.getView();
|
|
527
|
-
view.setCenter([x, y]);
|
|
528
|
-
if(zoom > 0){
|
|
529
|
-
view.setZoom(zoom);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
setZoom(zoom) {
|
|
534
|
-
if (!this.map) {
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
const view = this.map.getView();
|
|
538
|
-
view.setZoom(zoom);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
setMaxZoom(zoom){
|
|
564
|
+
setMaxZoom(zoom) {
|
|
542
565
|
if (!this.map) {
|
|
543
|
-
|
|
566
|
+
return;
|
|
544
567
|
}
|
|
545
568
|
const view = this.map.getView();
|
|
546
569
|
view.setMaxZoom(zoom)
|
|
547
570
|
}
|
|
548
|
-
setMinZoom(){
|
|
571
|
+
setMinZoom() {
|
|
549
572
|
if (!this.map) {
|
|
550
|
-
|
|
573
|
+
return;
|
|
551
574
|
}
|
|
552
575
|
const view = this.map.getView();
|
|
553
576
|
view.setMinZoom(zoom)
|
|
554
577
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
578
|
+
|
|
579
|
+
get getZoom() {
|
|
580
|
+
if (!this.map) {
|
|
581
|
+
return 0;
|
|
582
|
+
}
|
|
583
|
+
const view = this.map.getView();
|
|
584
|
+
return view.getZoom();
|
|
585
|
+
}
|
|
586
|
+
getCenter() {
|
|
587
|
+
if (!this.map) {
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
const view = this.map.getView();
|
|
591
|
+
let [x, y] = view.getCenter();
|
|
592
|
+
return [x, y];
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
fit(coordinates) {
|
|
596
|
+
fitNew(this.map, coordinates);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
createMarker(imgSrc, width = 15, height = 15) {
|
|
600
|
+
return new LMarker(imgSrc, width, height);
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
removeMarker(marker) {
|
|
604
|
+
this.map.removeOverlay(marker.getMarker());
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
lModifyEventArr() {
|
|
608
|
+
this.lModifyEventArr.length = 0;
|
|
609
|
+
this.polygonGeojsonArr.forEach((item, key) => {
|
|
610
|
+
const lMEvent = new LModifyEvent(item, this.map);
|
|
611
|
+
lMEvent.setActive();
|
|
612
|
+
this.lModifyEventArr.push(lMEvent);
|
|
613
|
+
});
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
removeLModifyEventArr() {
|
|
617
|
+
if (!this.lModifyEventArr.length) {
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
let item = null;
|
|
621
|
+
while ((item = this.lModifyEventArr.shift())) {
|
|
622
|
+
item.setActive(false);
|
|
623
|
+
item.remove();
|
|
624
|
+
item = null;
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
lModifyEvent() {
|
|
629
|
+
if (this.map && this.polygonGeojson) {
|
|
630
|
+
const lMEvent = new LModifyEvent(this.polygonGeojson, this.map);
|
|
631
|
+
lMEvent.setActive();
|
|
632
|
+
this.lMEvent = lMEvent;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
removeLModifyEvent() {
|
|
637
|
+
if (!this.lMEvent) {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
this.lMEvent.setActive(false);
|
|
641
|
+
this.lMEvent.remove();
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
convertWGS84GeoJSONgcj_encrypt(geoJSON) {
|
|
645
|
+
const {
|
|
646
|
+
bbox,
|
|
647
|
+
geometry,
|
|
648
|
+
properties
|
|
649
|
+
} = geoJSON;
|
|
650
|
+
const bboxArr = [];
|
|
651
|
+
for (let i = 0; i < bbox.length; i += 2) {
|
|
652
|
+
const {
|
|
653
|
+
lon,
|
|
654
|
+
lat
|
|
655
|
+
} = GPS.gcj_encrypt(bbox[i], bbox[i + 1]);
|
|
656
|
+
bboxArr.push(lon);
|
|
657
|
+
bboxArr.push(lat);
|
|
658
|
+
}
|
|
659
|
+
geoJSON.bbox = bboxArr;
|
|
660
|
+
const coordinates = geometry.coordinates;
|
|
661
|
+
const coordinateArr = new Array();
|
|
662
|
+
|
|
663
|
+
for (let i = 0; i < coordinates.length; i++) {
|
|
664
|
+
coordinateArr.push(coordinates[i]);
|
|
665
|
+
for (let j = 0; j < coordinates[i].length; j++) {
|
|
666
|
+
const arr = coordinates[i][j];
|
|
667
|
+
const {
|
|
668
|
+
lon,
|
|
669
|
+
lat
|
|
670
|
+
} = GPS.gcj_encrypt(arr[0], arr[1]);
|
|
671
|
+
coordinateArr[i][j] = [lon, lat];
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
geometry.coordinates = coordinateArr;
|
|
675
|
+
if (properties) {
|
|
676
|
+
if (properties.center) {
|
|
677
|
+
const [x, y] = properties.center;
|
|
678
|
+
const [lat, lon] = GPS.gcj_encrypt(x, y);
|
|
679
|
+
geoJSON.properties.center = [lat, lon];
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
return geoJSON;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
gcj_encryptConvertWGS84GeoJSON(geoJSON) {
|
|
686
|
+
const {
|
|
687
|
+
bbox,
|
|
688
|
+
geometry,
|
|
689
|
+
properties
|
|
690
|
+
} = geoJSON;
|
|
691
|
+
const bboxArr = [];
|
|
692
|
+
for (let i = 0; i < bbox.length; i += 2) {
|
|
693
|
+
const {
|
|
694
|
+
lon,
|
|
695
|
+
lat
|
|
696
|
+
} = GPS.gcj_decrypt(bbox[i], bbox[i + 1]);
|
|
697
|
+
bboxArr.push(lon);
|
|
698
|
+
bboxArr.push(lat);
|
|
699
|
+
}
|
|
700
|
+
geoJSON.bbox = bboxArr;
|
|
701
|
+
const coordinates = geometry.coordinates;
|
|
702
|
+
const coordinateArr = new Array();
|
|
703
|
+
for (let i = 0; i < coordinates.length; i++) {
|
|
704
|
+
coordinateArr.push(coordinates[i]);
|
|
705
|
+
for (let j = 0; j < coordinates[i].length; j++) {
|
|
706
|
+
const arr = coordinates[i][j];
|
|
707
|
+
const {
|
|
708
|
+
lon,
|
|
709
|
+
lat
|
|
710
|
+
} = GPS.gcj_decrypt(arr[0], arr[1]);
|
|
711
|
+
coordinateArr[i][j] = [lon, lat];
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
geometry.coordinates = coordinateArr;
|
|
715
|
+
if (properties) {
|
|
716
|
+
if (properties.center) {
|
|
717
|
+
const [x, y] = properties.center;
|
|
718
|
+
const [lat, lon] = GPS.gcj_decrypt(x, y);
|
|
719
|
+
geoJSON.properties.center = [lat, lon];
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
return geoJSON;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
gcj_encrypt(wgsLon, wgsLat) {
|
|
726
|
+
return GPS.gcj_encrypt(wgsLon, wgsLat);
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
gcj_decrypt(gcjLon, gcjLat) {
|
|
730
|
+
return GPS.gcj_decrypt(gcjLon, gcjLat);
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
formatArea() {
|
|
734
|
+
if (!this._lPolygon) {
|
|
735
|
+
return 0;
|
|
736
|
+
}
|
|
737
|
+
if (!this._lPolygon.getGeometry()) {
|
|
738
|
+
return 0;
|
|
739
|
+
}
|
|
740
|
+
return formatArea(this._lPolygon.getGeometry());
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
formatLength() {
|
|
744
|
+
if (!this._lPolygon) {
|
|
745
|
+
return 0;
|
|
746
|
+
}
|
|
747
|
+
if (!this._lPolygon.getGeometry()) {
|
|
748
|
+
return 0;
|
|
749
|
+
}
|
|
750
|
+
return formatLength(this._lPolygon.getGeometry());
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
createPolylinePointList(
|
|
754
|
+
data,
|
|
755
|
+
isGCJ02Point = false,
|
|
756
|
+
isFit = true,
|
|
757
|
+
callback = null,
|
|
758
|
+
type = 0,
|
|
759
|
+
) {
|
|
760
|
+
let polylines = new Array();
|
|
761
|
+
const polylinePoints = createPolylinePoints(data, isGCJ02Point);
|
|
762
|
+
polylines = addPolylinePoint(polylinePoints, this.map);
|
|
763
|
+
const gpsPoints = createGPSPoints(data, isGCJ02Point, this.am);
|
|
764
|
+
if (gpsPoints != null) {
|
|
765
|
+
let amGpsArr = this.am.getLngLats();
|
|
766
|
+
if (type) {
|
|
767
|
+
amGpsArr = this.am.getLngLatGCJ02();
|
|
768
|
+
}
|
|
769
|
+
fitNew(this.map, [
|
|
770
|
+
[amGpsArr[0], amGpsArr[1]],
|
|
771
|
+
[amGpsArr[2], amGpsArr[3]]
|
|
772
|
+
]);
|
|
773
|
+
|
|
774
|
+
}
|
|
775
|
+
return polylines;
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
async setAreaCenterPoint() {
|
|
779
|
+
let _code = '3301';
|
|
780
|
+
|
|
781
|
+
if (window.localStorage.getItem('user')) {
|
|
782
|
+
const user = JSON.parse(window.localStorage.getItem('user'));
|
|
783
|
+
_code = user['areaCode'];
|
|
784
|
+
}
|
|
785
|
+
|
|
786
|
+
const {
|
|
787
|
+
data
|
|
788
|
+
} = await getAreaCenter(_code);
|
|
789
|
+
const {
|
|
790
|
+
areaCode,
|
|
791
|
+
areaName,
|
|
792
|
+
centerLongitude,
|
|
793
|
+
centerLatitude
|
|
794
|
+
} = data;
|
|
795
|
+
window.localStorage.setItem('createPointData', JSON.stringify(data));
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
async getAreaCenterPoint(isGCJ02Point = false) {
|
|
799
|
+
// if (!window.localStorage.getItem('createPointData')) {
|
|
800
|
+
// await this.setAreaCenterPoint();
|
|
801
|
+
// }
|
|
802
|
+
// const obj = JSON.parse(window.localStorage.getItem('createPointData'));
|
|
803
|
+
// if (isGCJ02Point) {
|
|
804
|
+
// const {
|
|
805
|
+
// lon,
|
|
806
|
+
// lat
|
|
807
|
+
// } = GPS.gcj_encrypt(obj.centerLongitude, obj.centerLatitude);
|
|
808
|
+
// obj.centerLongitude = lon;
|
|
809
|
+
// obj.centerLatitude = lat;
|
|
810
|
+
// }
|
|
811
|
+
return obj;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
removeAreaCenterPoint() {
|
|
815
|
+
window.localStorage.removeItem('createPointData');
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
polygonStyle() {
|
|
819
|
+
return polygonStyle;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
removeMapsLayers() {
|
|
823
|
+
const arrs = this.map.getLayers().getArray();
|
|
824
|
+
for (let i = arrs.length; 0 <= i; i--) {
|
|
825
|
+
this.map.removeLayer(arrs[i]);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
removeOverlays() {
|
|
830
|
+
if (!this.map) {
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
const arrs = this.map.getOverlays().getArray();
|
|
834
|
+
for (let i = arrs.length; 0 <= i; i--) {
|
|
835
|
+
this.map.removeOverlay(arrs[i]);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
resetAM() {
|
|
840
|
+
this.am = null;
|
|
841
|
+
this.am = new AM();
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
createPolygonBoundary(geoJson, mode) {
|
|
845
|
+
const polygonBoundary = createPolygonBoundary(geoJson, mode);
|
|
846
|
+
this.polygonGeojsonArr.push(polygonBoundary);
|
|
847
|
+
this.map.addLayer(polygonBoundary);
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
createPolylinePointListNew(
|
|
851
|
+
data,
|
|
852
|
+
optins,
|
|
853
|
+
optins2 = {
|
|
854
|
+
isGCJ02Point: false,
|
|
855
|
+
isFit: false
|
|
856
|
+
}
|
|
857
|
+
) {
|
|
858
|
+
let polylines = new Array();
|
|
859
|
+
const polylinePoints = createPolylinePoints(data, false);
|
|
860
|
+
polylines = addPolylinePointNew(polylinePoints, this.map, optins);
|
|
861
|
+
const gpsPoints = createGPSPoints(data, false, this.am);
|
|
862
|
+
|
|
863
|
+
if (gpsPoints != null && optins2.isFit) {
|
|
864
|
+
let amGpsArr = this.am.getLngLats();
|
|
865
|
+
if (optins.type) {
|
|
866
|
+
amGpsArr = this.am.getLngLatGCJ02();
|
|
867
|
+
}
|
|
868
|
+
fitNew(this.map, [
|
|
869
|
+
[amGpsArr[0], amGpsArr[1]],
|
|
870
|
+
[amGpsArr[2], amGpsArr[3]]
|
|
871
|
+
]);
|
|
872
|
+
|
|
873
|
+
}
|
|
874
|
+
return polylines;
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
createLPolygonNew(options, map) {
|
|
878
|
+
this.lPolygonNewArr.push(new LPolygonNew(options, map));
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
setPolygonColor(
|
|
882
|
+
id,
|
|
883
|
+
colors = ['rgba(255,201,14, 0.4)', 'rgba(255,201,14, 1)']
|
|
884
|
+
) {
|
|
885
|
+
this.lPolygonNewArr.forEach((val) => {
|
|
886
|
+
if (val.Id == id) {
|
|
887
|
+
val.setPolygonColor(colors);
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
setPolygonColorAll(
|
|
894
|
+
colors = ['rgba(184, 233, 134, 0.56)', 'rgba(23, 168, 162, 0.56)']
|
|
895
|
+
) {
|
|
896
|
+
this.lPolygonNewArr.forEach((val) => {
|
|
897
|
+
val.setPolygonColor(colors);
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
removePolygonNew() {
|
|
902
|
+
this.lPolygonNewArr.forEach((val) => {
|
|
903
|
+
val.removePolygon();
|
|
904
|
+
val = null;
|
|
905
|
+
});
|
|
906
|
+
this.lPolygonNewArr = [];
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
caculateLL(lat1, lng1, lat2, lng2) {
|
|
910
|
+
return caculateLL(lat1, lng1, lat2, lng2);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
get LPolygonNewArr() {
|
|
914
|
+
return this.lPolygonNewArr;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
get isTruePolygon() {
|
|
918
|
+
if (!this._lPolygon) return false;
|
|
919
|
+
return this._lPolygon.isTruePolygon;
|
|
920
|
+
}
|
|
921
|
+
|
|
899
922
|
onCreateRectangle(callback) {
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
getRectangleData(){
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
}
|
|
921
|
-
|
|
922
|
-
getRectangleDataNew(){
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
}
|
|
934
|
-
|
|
935
|
-
|
|
923
|
+
|
|
924
|
+
if (this._lRectangle) {
|
|
925
|
+
this.clearRectangle();
|
|
926
|
+
}
|
|
927
|
+
const _this = this;
|
|
928
|
+
this._lRectangle = new LRectangle('Circle', this.map, (obj) => {});
|
|
929
|
+
return this._lRectangle;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
getRectangleData() {
|
|
933
|
+
if (!this._lRectangle) return [];
|
|
934
|
+
const coordinates = this._lRectangle.getCoordinates();
|
|
935
|
+
const pointArr = coordinates[0];
|
|
936
|
+
if (pointArr.length) {
|
|
937
|
+
const arr = [];
|
|
938
|
+
arr.push([pointArr[0][0], pointArr[1][1]]);
|
|
939
|
+
arr.push([pointArr[1][0], pointArr[2][1]]);
|
|
940
|
+
return arr;
|
|
941
|
+
};
|
|
942
|
+
return [];
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
getRectangleDataNew() {
|
|
946
|
+
if (!this._lRectangle) return [];
|
|
947
|
+
const coordinates = this._lRectangle.getCoordinates();
|
|
948
|
+
const pointArr = coordinates[0];
|
|
949
|
+
if (pointArr.length) {
|
|
950
|
+
const arr = [];
|
|
951
|
+
arr.push([pointArr[0][0], pointArr[1][1]]);
|
|
952
|
+
arr.push([pointArr[1][0], pointArr[2][1]]);
|
|
953
|
+
return arr;
|
|
954
|
+
};
|
|
955
|
+
return [];
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
|
|
936
959
|
clearRectangle() {
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
}
|
|
960
|
+
if (this.map && this._lRectangle) {
|
|
961
|
+
const coordinates = this._lRectangle.getCoordinates();
|
|
962
|
+
this._lRectangle.remove();
|
|
963
|
+
this._lRectangle = null;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
}
|