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.
@@ -1,944 +1,967 @@
1
-
2
1
  import 'ol/ol.css';
3
2
  import {
4
- AM,
5
- BingMapsServices,
6
- BingMapsServiceNew,
7
- CheckPoint,
8
- DraftingEvent,
9
- SvgModel,
10
- geo2svg,
11
- GPS,
12
- GrahamScan,
13
- LMap,
14
- MapConfig,
15
- formatArea,
16
- formatLength,
17
- createSpan,
18
- getVector,
19
- addInteraction,
20
- addInteraction1,
21
- getCoordinates,
22
- createGeoJson,
23
- getLngAndLatMaxMin,
24
- rayCasting,
25
- createPolygonGeojson,
26
- zoomIn,
27
- zoomOut,
28
- getCenterPoint,
29
- createGPSPoints,
30
- createPolylinePoints,
31
- fitNew,
32
- createRectangle,
33
- getColorStyle,
34
- createFill,
35
- polygonStyle,
36
- getLayer,
37
- getLayerNew,
38
- flyTo,
39
- tour,
40
- PolygonModel,
41
- createPolygonBoundary,
42
- caculateLL,
43
- LMarker,
44
- LModifyEvent,
45
- LOverlay,
46
- Polyline,
47
- addPolylinePoint,
48
- addPolylinePointNew,
49
- getDeepColorNew,
50
- LPolygonNew,
51
- Circular,
52
- LCluster,
53
- HelpTooltip,
54
- pathToLines,
55
- isTruePolygon,
56
- CrossHair,
57
- LDraw,
58
- FeaturePolygon,
59
- FeaturePolygonModel,
60
- LMarkerFont,
61
- LMessage,
62
- LPolygon,
63
- calculateCenter,
64
- MeasureTooltip,
65
- staticImage,
66
- TMapOptions,
67
- LCircle,
68
- ViewOptions,
69
- MapTypeEnum,
70
- MapLayersEnum,
71
- BingLayers,
72
- BDLayers,
73
- LRectangle,
74
- VectorMap
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
- constructor() {
79
- this.map = null;
80
- this._lPolygon = null;
81
- this._measureTooltip = null;
82
- this.currentLayer = [false, false, true];
83
- this.polygonGeojsonArr = [];
84
- this.polygonGeojson = null;
85
- this.lModifyEventArr = [];
86
- this.lmap = null;
87
- this.lMEvent = null;
88
- this.am = new AM();
89
- this.type = 2;
90
- this.lPolygonNewArr = new Array();
91
- this.polygonGeojsonMap = new Map();
92
- this.drawPolygonArr = new Set();
93
- this.drawLineArr = new Set();
94
- this._lRectangle=null;
95
- this.layers=null;
96
- }
97
- init(optins) {
98
- const {
99
- el,
100
- type,
101
- callback,
102
- viewOptions,
103
- layerType,
104
- mapType
105
- } = optins;
106
-
107
- this.initMap({
108
- el,
109
- callback,
110
- viewOptions,
111
- type,
112
- layerType
113
- });
114
- }
115
- initMap({
116
- el,
117
- callback,
118
- type,
119
- viewOptions,
120
- layerType
121
- }) {
122
- if (!this.lmap) {
123
-
124
- this.lmap = new LMap({
125
- controls: MapConfig.Defaults,
126
- });
127
- }
128
-
129
- setTimeout(() => {
130
- const _async = async () => {
131
- if (this.map) {
132
- this.map = null;
133
- }
134
- const {map,layers} = await this.lmap.onLoad(el,type, layerType);
135
- this.map=map;
136
- this.layers=layers;
137
- MapConfig.View = viewOptions;
138
- this.map.setView(MapConfig.View);
139
- if (callback) {
140
- callback(this.map,layers);
141
- }
142
- };
143
- _async();
144
- }, 100);
145
- }
146
- get getMapTypeLength() {
147
- return this.lmap.getMapTypeLength;
148
- }
149
- get getLayeTypeLength() {
150
- return this.lmap.getLayeTypeLength;
151
- }
152
- selectMapLayer(mapType, layerType) {
153
- if (!this.lmap) return 0;
154
- return this.lmap.selectLayers(mapType, layerType);
155
- }
156
- initBingMap(el, callback, viewOptions) {
157
- // this.clear();
158
- if (!this.lmap) {
159
- this.lmap = new LMap({
160
- controls: MapConfig.Defaults,
161
- });
162
- }
163
-
164
- setTimeout(() => {
165
- const _async = async () => {
166
- if (this.map) {
167
- this.map = null;
168
- }
169
- const {map,layers} = await this.lmap.onLoad(el, 2, 2);
170
- this.map=map;
171
- this.layers=layers;
172
- MapConfig.View = viewOptions;
173
- this.map.setView(MapConfig.View);
174
- if (callback) {
175
- callback(this.map,layers);
176
- }
177
- };
178
- _async();
179
- }, 100);
180
- }
181
-
182
- initBingMapNew(el, callback, viewOptions) {
183
-
184
- if (!this.lmap) {
185
- this.lmap = new LMap({
186
- controls: MapConfig.Defaults,
187
- });
188
- }
189
-
190
- setTimeout(() => {
191
- const _async = async () => {
192
- if (this.map) {
193
- this.map = null;
194
- }
195
- const {map,layers} = await this.lmap.onLoad(el, 0, 2);
196
- this.map=map;
197
- this.layers=layers;
198
- MapConfig.View = viewOptions;
199
- this.map.setView(MapConfig.View);
200
- if (callback) {
201
- callback(this.map,layers);
202
- }
203
- };
204
- _async();
205
- }, 100);
206
-
207
- // if (!this.lmap) {
208
- // this.lmap = new LMap({
209
- // controls: MapConfig.Defaults,
210
- // });
211
- // }
212
-
213
- // setTimeout(() => {
214
- // const _async = async () => {
215
- // if (this.map) {
216
- // this.map = null;
217
- // }
218
- // this.map = await this.lmap.onLoad(el,3,1);
219
- // MapConfig.View = viewOptions;
220
- // this.map.setView(MapConfig.View);
221
- // if (callback) {
222
- // callback(this.map);
223
- // }
224
- // };
225
- // _async();
226
- // }, 100);
227
- }
228
-
229
- async initVectorMap(opt) {
230
- const {el,isAnalysisBBOX,isAnalysisCenter,callback,delaytime,isDrag} = opt;
231
- const vmap = new VectorMap({
232
- isAnalysisBBOX,
233
- isAnalysisCenter,
234
- isDrag,
235
- callback:r=> {
236
- if(callback){
237
- callback(r);
238
- }
239
- }
240
- });
241
-
242
- return new Promise(r=> {
243
- setTimeout(async ()=> {
244
- const map = await vmap.onLoad(el);
245
- r({map,vmap});
246
- },delaytime ? delaytime:100);
247
- });
248
-
249
- }
250
-
251
- getVectorLayerView() {
252
- return MapConfig.getVectorLayerView;
253
- }
254
-
255
- onSetLayers(type) {
256
- this.type = type;
257
- this.currentLayer = this.currentLayer.map((r) => (r = false));
258
- this.currentLayer[type] = true;
259
- this.removeLayers(type);
260
- this.addLayers(type);
261
- }
262
-
263
- removeLayers(type) {
264
- MapConfig.TMapLayerArr[type].forEach((val, key) => {
265
- this.map.removeLayer(val);
266
- });
267
- }
268
-
269
- addLayers(type) {
270
- MapConfig.TMapLayerArr[type].forEach((val, key) => {
271
- this.map.addLayer(val);
272
- });
273
- }
274
-
275
- onCreatePolygon(callback,type) {
276
- if (this.polygonGeojson) {
277
- this.map.removeLayer(this.polygonGeojson);
278
- }
279
- if (this._lPolygon) {
280
- this.clearlPolygon();
281
- // this._removeMeasureTooltip();
282
- }
283
- const _this = this;
284
- this._lPolygon = new LPolygon(this.map, {
285
- strokeColor: 'rgba(255,201,14, 1)',
286
- fillColor: 'rgba(255,201,14, 0.4)',
287
- type
288
- });
289
- return this._lPolygon;
290
- // if (callback) {
291
- // callback();
292
- // }
293
- }
294
-
295
- skipCurrentDraw(){
296
- if (this._lPolygon) {
297
- this._lPolygon.skipCurrentDraw();
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
- onCancel() {
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
- return;
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
- return;
573
+ return;
551
574
  }
552
575
  const view = this.map.getView();
553
576
  view.setMinZoom(zoom)
554
577
  }
555
-
556
- get getZoom() {
557
- if (!this.map) {
558
- return 0;
559
- }
560
- const view = this.map.getView();
561
- return view.getZoom();
562
- }
563
- getCenter() {
564
- if (!this.map) {
565
- return;
566
- }
567
- const view = this.map.getView();
568
- let [x, y] = view.getCenter();
569
- return [x, y];
570
- }
571
-
572
- fit(coordinates) {
573
- fitNew(this.map, coordinates);
574
- }
575
-
576
- createMarker(imgSrc, width = 15, height = 15) {
577
- return new LMarker(imgSrc, width, height);
578
- }
579
-
580
- removeMarker(marker) {
581
- this.map.removeOverlay(marker.getMarker());
582
- }
583
-
584
- lModifyEventArr() {
585
- this.lModifyEventArr.length = 0;
586
- this.polygonGeojsonArr.forEach((item, key) => {
587
- const lMEvent = new LModifyEvent(item, this.map);
588
- lMEvent.setActive();
589
- this.lModifyEventArr.push(lMEvent);
590
- });
591
- }
592
-
593
- removeLModifyEventArr() {
594
- if (!this.lModifyEventArr.length) {
595
- return;
596
- }
597
- let item = null;
598
- while ((item = this.lModifyEventArr.shift())) {
599
- item.setActive(false);
600
- item.remove();
601
- item = null;
602
- }
603
- }
604
-
605
- lModifyEvent() {
606
- if (this.map && this.polygonGeojson) {
607
- const lMEvent = new LModifyEvent(this.polygonGeojson, this.map);
608
- lMEvent.setActive();
609
- this.lMEvent = lMEvent;
610
- }
611
- }
612
-
613
- removeLModifyEvent() {
614
- if (!this.lMEvent) {
615
- return;
616
- }
617
- this.lMEvent.setActive(false);
618
- this.lMEvent.remove();
619
- }
620
-
621
- convertWGS84GeoJSONgcj_encrypt(geoJSON) {
622
- const {
623
- bbox,
624
- geometry,
625
- properties
626
- } = geoJSON;
627
- const bboxArr = [];
628
- for (let i = 0; i < bbox.length; i += 2) {
629
- const {
630
- lon,
631
- lat
632
- } = GPS.gcj_encrypt(bbox[i], bbox[i + 1]);
633
- bboxArr.push(lon);
634
- bboxArr.push(lat);
635
- }
636
- geoJSON.bbox = bboxArr;
637
- const coordinates = geometry.coordinates;
638
- const coordinateArr = new Array();
639
-
640
- for (let i = 0; i < coordinates.length; i++) {
641
- coordinateArr.push(coordinates[i]);
642
- for (let j = 0; j < coordinates[i].length; j++) {
643
- const arr = coordinates[i][j];
644
- const {
645
- lon,
646
- lat
647
- } = GPS.gcj_encrypt(arr[0], arr[1]);
648
- coordinateArr[i][j] = [lon, lat];
649
- }
650
- }
651
- geometry.coordinates = coordinateArr;
652
- if (properties) {
653
- if (properties.center) {
654
- const [x, y] = properties.center;
655
- const [lat, lon] = GPS.gcj_encrypt(x, y);
656
- geoJSON.properties.center = [lat, lon];
657
- }
658
- }
659
- return geoJSON;
660
- }
661
-
662
- gcj_encryptConvertWGS84GeoJSON(geoJSON) {
663
- const {
664
- bbox,
665
- geometry,
666
- properties
667
- } = geoJSON;
668
- const bboxArr = [];
669
- for (let i = 0; i < bbox.length; i += 2) {
670
- const {
671
- lon,
672
- lat
673
- } = GPS.gcj_decrypt(bbox[i], bbox[i + 1]);
674
- bboxArr.push(lon);
675
- bboxArr.push(lat);
676
- }
677
- geoJSON.bbox = bboxArr;
678
- const coordinates = geometry.coordinates;
679
- const coordinateArr = new Array();
680
- for (let i = 0; i < coordinates.length; i++) {
681
- coordinateArr.push(coordinates[i]);
682
- for (let j = 0; j < coordinates[i].length; j++) {
683
- const arr = coordinates[i][j];
684
- const {
685
- lon,
686
- lat
687
- } = GPS.gcj_decrypt(arr[0], arr[1]);
688
- coordinateArr[i][j] = [lon, lat];
689
- }
690
- }
691
- geometry.coordinates = coordinateArr;
692
- if (properties) {
693
- if (properties.center) {
694
- const [x, y] = properties.center;
695
- const [lat, lon] = GPS.gcj_decrypt(x, y);
696
- geoJSON.properties.center = [lat, lon];
697
- }
698
- }
699
- return geoJSON;
700
- }
701
-
702
- gcj_encrypt(wgsLon, wgsLat) {
703
- return GPS.gcj_encrypt(wgsLon, wgsLat);
704
- }
705
-
706
- gcj_decrypt(gcjLon, gcjLat) {
707
- return GPS.gcj_decrypt(gcjLon, gcjLat);
708
- }
709
-
710
- formatArea() {
711
- if (!this._lPolygon) {
712
- return 0;
713
- }
714
- if (!this._lPolygon.getGeometry()) {
715
- return 0;
716
- }
717
- return formatArea(this._lPolygon.getGeometry());
718
- }
719
-
720
- formatLength() {
721
- if (!this._lPolygon) {
722
- return 0;
723
- }
724
- if (!this._lPolygon.getGeometry()) {
725
- return 0;
726
- }
727
- return formatLength(this._lPolygon.getGeometry());
728
- }
729
-
730
- createPolylinePointList(
731
- data,
732
- isGCJ02Point = false,
733
- isFit = true,
734
- callback = null,
735
- type=0,
736
- ) {
737
- let polylines = new Array();
738
- const polylinePoints = createPolylinePoints(data, isGCJ02Point);
739
- polylines = addPolylinePoint(polylinePoints, this.map);
740
- const gpsPoints = createGPSPoints(data, isGCJ02Point, this.am);
741
- if (gpsPoints != null) {
742
- let amGpsArr = this.am.getLngLats();
743
- if(type){
744
- amGpsArr = this.am.getLngLatGCJ02();
745
- }
746
- fitNew(this.map, [
747
- [amGpsArr[0], amGpsArr[1]],
748
- [amGpsArr[2], amGpsArr[3]]
749
- ]);
750
-
751
- }
752
- return polylines;
753
- }
754
-
755
- async setAreaCenterPoint() {
756
- let _code = '3301';
757
-
758
- if (window.localStorage.getItem('user')) {
759
- const user = JSON.parse(window.localStorage.getItem('user'));
760
- _code = user['areaCode'];
761
- }
762
-
763
- const {
764
- data
765
- } = await getAreaCenter(_code);
766
- const {
767
- areaCode,
768
- areaName,
769
- centerLongitude,
770
- centerLatitude
771
- } = data;
772
- window.localStorage.setItem('createPointData', JSON.stringify(data));
773
- }
774
-
775
- async getAreaCenterPoint(isGCJ02Point = false) {
776
- // if (!window.localStorage.getItem('createPointData')) {
777
- // await this.setAreaCenterPoint();
778
- // }
779
- // const obj = JSON.parse(window.localStorage.getItem('createPointData'));
780
- // if (isGCJ02Point) {
781
- // const {
782
- // lon,
783
- // lat
784
- // } = GPS.gcj_encrypt(obj.centerLongitude, obj.centerLatitude);
785
- // obj.centerLongitude = lon;
786
- // obj.centerLatitude = lat;
787
- // }
788
- return obj;
789
- }
790
-
791
- removeAreaCenterPoint() {
792
- window.localStorage.removeItem('createPointData');
793
- }
794
-
795
- polygonStyle() {
796
- return polygonStyle;
797
- }
798
-
799
- removeMapsLayers() {
800
- const arrs = this.map.getLayers().getArray();
801
- for (let i = arrs.length; 0 <= i; i--) {
802
- this.map.removeLayer(arrs[i]);
803
- }
804
- }
805
-
806
- removeOverlays() {
807
- if (!this.map) {
808
- return;
809
- }
810
- const arrs = this.map.getOverlays().getArray();
811
- for (let i = arrs.length; 0 <= i; i--) {
812
- this.map.removeOverlay(arrs[i]);
813
- }
814
- }
815
-
816
- resetAM() {
817
- this.am = null;
818
- this.am = new AM();
819
- }
820
-
821
- createPolygonBoundary(geoJson, mode) {
822
- const polygonBoundary = createPolygonBoundary(geoJson, mode);
823
- this.polygonGeojsonArr.push(polygonBoundary);
824
- this.map.addLayer(polygonBoundary);
825
- }
826
-
827
- createPolylinePointListNew(
828
- data,
829
- optins,
830
- optins2 = {
831
- isGCJ02Point: false,
832
- isFit: false
833
- }
834
- ) {
835
- let polylines = new Array();
836
- const polylinePoints = createPolylinePoints(data, false);
837
- polylines = addPolylinePointNew(polylinePoints, this.map, optins);
838
- const gpsPoints = createGPSPoints(data, false, this.am);
839
-
840
- if (gpsPoints != null && optins2.isFit) {
841
- let amGpsArr = this.am.getLngLats();
842
- if(optins.type){
843
- amGpsArr = this.am.getLngLatGCJ02();
844
- }
845
- fitNew(this.map, [
846
- [amGpsArr[0], amGpsArr[1]],
847
- [amGpsArr[2], amGpsArr[3]]
848
- ]);
849
-
850
- }
851
- return polylines;
852
- }
853
-
854
- createLPolygonNew(options, map) {
855
- this.lPolygonNewArr.push(new LPolygonNew(options, map));
856
- }
857
-
858
- setPolygonColor(
859
- id,
860
- colors = ['rgba(255,201,14, 0.4)', 'rgba(255,201,14, 1)']
861
- ) {
862
- this.lPolygonNewArr.forEach((val) => {
863
- if (val.Id == id) {
864
- val.setPolygonColor(colors);
865
- return;
866
- }
867
- });
868
- }
869
-
870
- setPolygonColorAll(
871
- colors = ['rgba(184, 233, 134, 0.56)', 'rgba(23, 168, 162, 0.56)']
872
- ) {
873
- this.lPolygonNewArr.forEach((val) => {
874
- val.setPolygonColor(colors);
875
- });
876
- }
877
-
878
- removePolygonNew() {
879
- this.lPolygonNewArr.forEach((val) => {
880
- val.removePolygon();
881
- val = null;
882
- });
883
- this.lPolygonNewArr = [];
884
- }
885
-
886
- caculateLL(lat1, lng1, lat2, lng2) {
887
- return caculateLL(lat1, lng1, lat2, lng2);
888
- }
889
-
890
- get LPolygonNewArr() {
891
- return this.lPolygonNewArr;
892
- }
893
-
894
- get isTruePolygon() {
895
- if (!this._lPolygon) return false;
896
- return this._lPolygon.isTruePolygon;
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
- if (this._lRectangle) {
902
- this.clearRectangle();
903
- }
904
- const _this = this;
905
- this._lRectangle = new LRectangle('Circle', this.map, (obj) => {});
906
- return this._lRectangle;
907
- }
908
-
909
- getRectangleData(){
910
- if(!this._lRectangle) return [];
911
- const coordinates = this._lRectangle.getCoordinates();
912
- const pointArr= coordinates[0];
913
- if(pointArr.length){
914
- const arr= [];
915
- arr.push([pointArr[0][0], pointArr[1][1]]);
916
- arr.push([pointArr[1][0], pointArr[2][1]]);
917
- return arr;
918
- };
919
- return [];
920
- }
921
-
922
- getRectangleDataNew(){
923
- if(!this._lRectangle) return [];
924
- const coordinates = this._lRectangle.getCoordinates();
925
- const pointArr= coordinates[0];
926
- if(pointArr.length){
927
- const arr= [];
928
- arr.push([pointArr[0][0], pointArr[1][1]]);
929
- arr.push([pointArr[1][0], pointArr[2][1]]);
930
- return arr;
931
- };
932
- return [];
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
- if (this.map && this._lRectangle) {
938
- const coordinates = this._lRectangle.getCoordinates();
939
- this._lRectangle.remove();
940
- this._lRectangle = null;
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
+ }