ry-vue-map 0.2.1 → 0.2.3

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