hy-dispatch-ui-v3 0.2.83 → 0.2.84
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/es/components/hyMap/js/index.mjs +1 -0
- package/es/utils/map/hook/bigMap.mjs +103 -124
- package/es/utils/map/hook/gaode.mjs +3 -0
- package/es/utils/map/hook/leafletjs.mjs +78 -113
- package/es/utils/map/index.mjs +4 -4
- package/es/utils/map/js/mapProxy.mjs +24 -5
- package/es/version.mjs +1 -1
- package/lib/components/hyMap/js/index.js +1 -0
- package/lib/utils/map/hook/bigMap.js +102 -123
- package/lib/utils/map/hook/gaode.js +3 -0
- package/lib/utils/map/hook/leafletjs.js +77 -112
- package/lib/utils/map/index.js +4 -4
- package/lib/utils/map/js/mapProxy.js +24 -4
- package/lib/version.js +1 -1
- package/package.json +1 -1
|
@@ -87,22 +87,7 @@ const generalMapMethods = {
|
|
|
87
87
|
*/
|
|
88
88
|
getBounds(target) {
|
|
89
89
|
const bounds = target.getBounds();
|
|
90
|
-
|
|
91
|
-
const northEast = bounds.getNorthEast();
|
|
92
|
-
const center = bounds.getCenter();
|
|
93
|
-
bounds.getSouthWest = () => {
|
|
94
|
-
const { lat, lng } = latAndLngCheck(southWest);
|
|
95
|
-
return L.latLng(lat, lng);
|
|
96
|
-
};
|
|
97
|
-
bounds.getNorthEast = () => {
|
|
98
|
-
const { lat, lng } = latAndLngCheck(northEast);
|
|
99
|
-
return L.latLng(lat, lng);
|
|
100
|
-
};
|
|
101
|
-
bounds.getCenter = () => {
|
|
102
|
-
const { lat, lng } = latAndLngCheck(center);
|
|
103
|
-
return L.latLng(lat, lng);
|
|
104
|
-
};
|
|
105
|
-
return bounds;
|
|
90
|
+
return L.latLngBounds(latAndLngCheck(bounds.getSouthWest()), latAndLngCheck(bounds.getNorthEast()));
|
|
106
91
|
},
|
|
107
92
|
/**
|
|
108
93
|
* 包装Map实例
|
|
@@ -110,13 +95,7 @@ const generalMapMethods = {
|
|
|
110
95
|
* @returns {Proxy} 包装后的Map
|
|
111
96
|
*/
|
|
112
97
|
getMap(map) {
|
|
113
|
-
return
|
|
114
|
-
getCenter(target) {
|
|
115
|
-
const center = target.getCenter();
|
|
116
|
-
const { lng, lat } = latAndLngCheck(center);
|
|
117
|
-
return L.latLng(lat, lng);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
98
|
+
return getInitMap(map);
|
|
120
99
|
},
|
|
121
100
|
/**
|
|
122
101
|
* 包装Bounds(导出转换)
|
|
@@ -125,22 +104,7 @@ const generalMapMethods = {
|
|
|
125
104
|
*/
|
|
126
105
|
getBoundsExport(target) {
|
|
127
106
|
const bounds = target.getBounds();
|
|
128
|
-
|
|
129
|
-
const northEast = bounds.getNorthEast();
|
|
130
|
-
const center = bounds.getCenter();
|
|
131
|
-
bounds.getSouthWest = () => {
|
|
132
|
-
const { lat, lng } = latAndLngCheckExport(southWest);
|
|
133
|
-
return L.latLng(lat, lng);
|
|
134
|
-
};
|
|
135
|
-
bounds.getNorthEast = () => {
|
|
136
|
-
const { lat, lng } = latAndLngCheckExport(northEast);
|
|
137
|
-
return L.latLng(lat, lng);
|
|
138
|
-
};
|
|
139
|
-
bounds.getCenter = () => {
|
|
140
|
-
const { lat, lng } = latAndLngCheckExport(center);
|
|
141
|
-
return L.latLng(lat, lng);
|
|
142
|
-
};
|
|
143
|
-
return bounds;
|
|
107
|
+
return L.latLngBounds(latAndLngCheckExport(bounds.getSouthWest()), latAndLngCheckExport(bounds.getNorthEast()));
|
|
144
108
|
}
|
|
145
109
|
};
|
|
146
110
|
function latAndLngCheck(item) {
|
|
@@ -160,6 +124,7 @@ function latAndLngCheckExport(item) {
|
|
|
160
124
|
function latLngListCheck(dataList = []) {
|
|
161
125
|
return dataList.map((item) => {
|
|
162
126
|
const isArray = Array.isArray(item);
|
|
127
|
+
if (isArray && (item.length === 0 || typeof item[0] === "object")) return latLngListCheck(item);
|
|
163
128
|
const { lat, lng } = latAndLngCheck(item);
|
|
164
129
|
return isArray ? [lat, lng] : { ...item, lat, lng };
|
|
165
130
|
});
|
|
@@ -167,6 +132,7 @@ function latLngListCheck(dataList = []) {
|
|
|
167
132
|
function latLngListCheckExport(dataList = []) {
|
|
168
133
|
return dataList.map((item) => {
|
|
169
134
|
const isArray = Array.isArray(item);
|
|
135
|
+
if (isArray && (item.length === 0 || typeof item[0] === "object")) return latLngListCheckExport(item);
|
|
170
136
|
const { lat, lng } = latAndLngCheckExport(item);
|
|
171
137
|
return isArray ? [lat, lng] : { ...item, lat, lng };
|
|
172
138
|
});
|
|
@@ -183,32 +149,15 @@ function circleToPolygonPoints(center, radius, asObject = false) {
|
|
|
183
149
|
return points;
|
|
184
150
|
}
|
|
185
151
|
function wrapDrawLayer(layer) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const item = JSON.parse(JSON.stringify(latLngList[0]));
|
|
196
|
-
return [latLngListCheckExport([...item])];
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
layer.getBounds = () => {
|
|
200
|
-
const southWest = bounds.getSouthWest();
|
|
201
|
-
const northEast = bounds.getNorthEast();
|
|
202
|
-
bounds.getSouthWest = () => {
|
|
203
|
-
const { lat, lng } = latAndLngCheckExport(southWest);
|
|
204
|
-
return L.latLng(lat, lng);
|
|
205
|
-
};
|
|
206
|
-
bounds.getNorthEast = () => {
|
|
207
|
-
const { lat, lng } = latAndLngCheckExport(northEast);
|
|
208
|
-
return L.latLng(lat, lng);
|
|
209
|
-
};
|
|
210
|
-
return bounds;
|
|
211
|
-
};
|
|
152
|
+
return mapProxy.createNativeMapProxy(layer, {
|
|
153
|
+
getLatLngs: function(target) {
|
|
154
|
+
const points = target.getLatLngs ? target.getLatLngs() : [circleToPolygonPoints(target.getLatLng(), target.getRadius() / 1e3, true)];
|
|
155
|
+
return latLngListCheckExport(points);
|
|
156
|
+
},
|
|
157
|
+
getBounds: function(target) {
|
|
158
|
+
return generalMapMethods.getBoundsExport(target);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
212
161
|
}
|
|
213
162
|
function createClickHandler(fn, context, target, withOriginEvent = false) {
|
|
214
163
|
return (e) => {
|
|
@@ -300,14 +249,15 @@ class Leafletjs extends events.EventEmitter {
|
|
|
300
249
|
return generalMapMethods.getBoundsExport(target);
|
|
301
250
|
},
|
|
302
251
|
getLatLngs: function(target) {
|
|
303
|
-
|
|
304
|
-
const item = JSON.parse(JSON.stringify(latLngList[0]));
|
|
305
|
-
return [latLngListCheckExport([...item])];
|
|
252
|
+
return latLngListCheckExport(target.getLatLngs());
|
|
306
253
|
},
|
|
307
254
|
// 修改位置
|
|
308
255
|
setLatLngs: function(target, lngLatList = []) {
|
|
309
256
|
return target.setLatLngs(latLngListCheck(lngLatList));
|
|
310
257
|
},
|
|
258
|
+
addLatLng: function(target, point) {
|
|
259
|
+
return target.addLatLng(latAndLngCheck(point));
|
|
260
|
+
},
|
|
311
261
|
on: function(target, types, fn, context) {
|
|
312
262
|
if (types === "click") {
|
|
313
263
|
const customClickHandler = createClickHandler(fn, context, target);
|
|
@@ -321,7 +271,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
321
271
|
return target.off(types, wrappedFn || fn, context);
|
|
322
272
|
}
|
|
323
273
|
};
|
|
324
|
-
return mapProxy.
|
|
274
|
+
return mapProxy.createNativeMapProxy(polygon, handlers);
|
|
325
275
|
});
|
|
326
276
|
this.initParams = request;
|
|
327
277
|
this.tileLayerList = [];
|
|
@@ -354,16 +304,23 @@ class Leafletjs extends events.EventEmitter {
|
|
|
354
304
|
wrappedHandlers.clear();
|
|
355
305
|
}
|
|
356
306
|
},
|
|
357
|
-
fitBounds: function(target, params) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
307
|
+
fitBounds: function(target, params, options) {
|
|
308
|
+
const bounds = L.latLngBounds();
|
|
309
|
+
const extendBounds = (item) => {
|
|
310
|
+
if (item?.getBounds) {
|
|
311
|
+
const layer = item.getInitLayer ? item.getInitLayer() : item;
|
|
312
|
+
bounds.extend(layer.getBounds());
|
|
313
|
+
} else if (item?.getSouthWest) {
|
|
314
|
+
bounds.extend(latAndLngCheck(item.getSouthWest()));
|
|
315
|
+
bounds.extend(latAndLngCheck(item.getNorthEast()));
|
|
316
|
+
} else if (Array.isArray(item) && (item.length === 0 || typeof item[0] === "object")) {
|
|
317
|
+
item.forEach(extendBounds);
|
|
318
|
+
} else {
|
|
319
|
+
bounds.extend(latAndLngCheck(item));
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
extendBounds(params);
|
|
323
|
+
return target.fitBounds(bounds, options);
|
|
367
324
|
},
|
|
368
325
|
// 获取中心点
|
|
369
326
|
getCenter: function(target) {
|
|
@@ -377,18 +334,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
377
334
|
},
|
|
378
335
|
// 四个角
|
|
379
336
|
getBounds: function(target) {
|
|
380
|
-
|
|
381
|
-
const southWest = bounds.getSouthWest();
|
|
382
|
-
const northEast = bounds.getNorthEast();
|
|
383
|
-
bounds.getSouthWest = () => {
|
|
384
|
-
const { lat: lat2, lng: lng2 } = latAndLngCheckExport(southWest);
|
|
385
|
-
return L.latLng(lat2, lng2);
|
|
386
|
-
};
|
|
387
|
-
bounds.getNorthEast = () => {
|
|
388
|
-
const { lat: lat2, lng: lng2 } = latAndLngCheckExport(northEast);
|
|
389
|
-
return L.latLng(lat2, lng2);
|
|
390
|
-
};
|
|
391
|
-
return bounds;
|
|
337
|
+
return generalMapMethods.getBoundsExport(target);
|
|
392
338
|
},
|
|
393
339
|
// 移动至目标位置
|
|
394
340
|
panTo: function(target, center2, options) {
|
|
@@ -409,7 +355,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
409
355
|
} else if (types === "pm:create") {
|
|
410
356
|
const customClickHandler = (e) => {
|
|
411
357
|
const newEvent = { ...e };
|
|
412
|
-
wrapDrawLayer(newEvent.layer);
|
|
358
|
+
newEvent.layer = wrapDrawLayer(newEvent.layer);
|
|
413
359
|
fn.call(context || target, newEvent);
|
|
414
360
|
};
|
|
415
361
|
wrappedHandlers.remember(types, fn, customClickHandler);
|
|
@@ -426,7 +372,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
426
372
|
_this.setLayersUrl(target, satelliteMap !== 2);
|
|
427
373
|
}
|
|
428
374
|
};
|
|
429
|
-
const map = mapProxy.
|
|
375
|
+
const map = mapProxy.createNativeMapProxy(newMap, handlers);
|
|
430
376
|
map.id = createUniqueId();
|
|
431
377
|
map.whenReady(() => {
|
|
432
378
|
if (option.completeCallbacks) {
|
|
@@ -573,16 +519,16 @@ class Leafletjs extends events.EventEmitter {
|
|
|
573
519
|
}
|
|
574
520
|
// 地图图层
|
|
575
521
|
layerGroup(map, markers = []) {
|
|
576
|
-
const layerGroup = L.layerGroup(markers).addTo(getInitMap(map));
|
|
522
|
+
const layerGroup = L.layerGroup(markers.map((item) => item.getInitLayer?.() || item)).addTo(getInitMap(map));
|
|
577
523
|
const handlers = {
|
|
578
524
|
addLayer: function(target, addItem) {
|
|
579
|
-
return target.addLayer(addItem);
|
|
525
|
+
return target.addLayer(addItem.getInitLayer?.() || addItem);
|
|
580
526
|
},
|
|
581
527
|
clearLayers: function(target) {
|
|
582
528
|
return target.clearLayers();
|
|
583
529
|
}
|
|
584
530
|
};
|
|
585
|
-
return mapProxy.
|
|
531
|
+
return mapProxy.createNativeMapProxy(layerGroup, handlers);
|
|
586
532
|
}
|
|
587
533
|
// 获取esri对象
|
|
588
534
|
esriFn() {
|
|
@@ -653,7 +599,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
653
599
|
// 更改标记位置。
|
|
654
600
|
setLatLng: function(target, lngAndLat) {
|
|
655
601
|
const { lat, lng } = latAndLngCheck(lngAndLat);
|
|
656
|
-
target.setLatLng([lat, lng]);
|
|
602
|
+
return target.setLatLng([lat, lng]);
|
|
657
603
|
},
|
|
658
604
|
setIcon: function(target, iconParams) {
|
|
659
605
|
target.setIcon(iconParams.divIcon);
|
|
@@ -671,7 +617,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
671
617
|
return target.off(types, wrappedFn || fn, context);
|
|
672
618
|
}
|
|
673
619
|
};
|
|
674
|
-
const markerProxy = mapProxy.
|
|
620
|
+
const markerProxy = mapProxy.createNativeMapProxy(marker, handlers);
|
|
675
621
|
marker._proxy = markerProxy;
|
|
676
622
|
return markerProxy;
|
|
677
623
|
}
|
|
@@ -707,6 +653,9 @@ class Leafletjs extends events.EventEmitter {
|
|
|
707
653
|
addLayers: function(target, markerList2 = []) {
|
|
708
654
|
target.addLayers(toNativeMarkers(markerList2, target));
|
|
709
655
|
},
|
|
656
|
+
clearLayers: function(target) {
|
|
657
|
+
target.clearLayers();
|
|
658
|
+
},
|
|
710
659
|
// 销毁聚合内所有 marker 并清空图层
|
|
711
660
|
destroyAll: function(target) {
|
|
712
661
|
target.getLayers().forEach((layer) => {
|
|
@@ -720,7 +669,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
720
669
|
target.clearLayers();
|
|
721
670
|
}
|
|
722
671
|
};
|
|
723
|
-
const newDisplayCluster = mapProxy.
|
|
672
|
+
const newDisplayCluster = mapProxy.createNativeMapProxy(displayCluster, handlers);
|
|
724
673
|
newDisplayCluster.addLayers(markerList);
|
|
725
674
|
return newDisplayCluster;
|
|
726
675
|
}
|
|
@@ -739,6 +688,12 @@ class Leafletjs extends events.EventEmitter {
|
|
|
739
688
|
latLngList = [lat, lng];
|
|
740
689
|
const circle = L.circle(latLngList, option);
|
|
741
690
|
const handlers = {
|
|
691
|
+
getLatLng: function(target) {
|
|
692
|
+
return L.latLng(latAndLngCheckExport(target.getLatLng()));
|
|
693
|
+
},
|
|
694
|
+
setLatLng: function(target, point) {
|
|
695
|
+
return target.setLatLng(latAndLngCheck(point));
|
|
696
|
+
},
|
|
742
697
|
addTo: function(target, map) {
|
|
743
698
|
return target.addTo(generalMapMethods.getMap(map));
|
|
744
699
|
},
|
|
@@ -752,7 +707,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
752
707
|
return [latLngListCheckExport(points)];
|
|
753
708
|
}
|
|
754
709
|
};
|
|
755
|
-
return mapProxy.
|
|
710
|
+
return mapProxy.createNativeMapProxy(circle, handlers);
|
|
756
711
|
}
|
|
757
712
|
// 自定义 popup
|
|
758
713
|
Popup(option) {
|
|
@@ -762,6 +717,10 @@ class Leafletjs extends events.EventEmitter {
|
|
|
762
717
|
};
|
|
763
718
|
const popup = L.popup(option);
|
|
764
719
|
const handlers = {
|
|
720
|
+
getLatLng: function(target) {
|
|
721
|
+
const point = target.getLatLng();
|
|
722
|
+
return point ? L.latLng(latAndLngCheckExport(point)) : point;
|
|
723
|
+
},
|
|
765
724
|
addTo: function(target, map) {
|
|
766
725
|
return target.addTo(generalMapMethods.getMap(map));
|
|
767
726
|
},
|
|
@@ -786,7 +745,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
786
745
|
return target.setLatLng(latLngList);
|
|
787
746
|
}
|
|
788
747
|
};
|
|
789
|
-
return mapProxy.
|
|
748
|
+
return mapProxy.createNativeMapProxy(popup, handlers);
|
|
790
749
|
}
|
|
791
750
|
// 自定义 线条
|
|
792
751
|
Polyline(latLngList = [], option = {}) {
|
|
@@ -796,6 +755,9 @@ class Leafletjs extends events.EventEmitter {
|
|
|
796
755
|
const polyline = L.polyline(latLngList, option);
|
|
797
756
|
const wrappedHandlers = mapProxy.createWrappedHandlerStore();
|
|
798
757
|
const handlers = {
|
|
758
|
+
getLatLngs: function(target) {
|
|
759
|
+
return latLngListCheckExport(target.getLatLngs());
|
|
760
|
+
},
|
|
799
761
|
addTo: function(target, map) {
|
|
800
762
|
return target.addTo(generalMapMethods.getMap(map));
|
|
801
763
|
},
|
|
@@ -824,22 +786,25 @@ class Leafletjs extends events.EventEmitter {
|
|
|
824
786
|
return target.off(types, wrappedFn || fn, context);
|
|
825
787
|
}
|
|
826
788
|
};
|
|
827
|
-
return mapProxy.
|
|
789
|
+
return mapProxy.createNativeMapProxy(polyline, handlers);
|
|
828
790
|
}
|
|
829
791
|
MotionPolyline(latLngList = [], option = {}, motionOption = {}, markerOption = {}) {
|
|
830
792
|
if (latLngList && latLngList.length !== 0) {
|
|
831
793
|
latLngList = latLngListCheck(latLngList);
|
|
832
794
|
}
|
|
833
795
|
const polyline = L.motion.polyline(latLngList, option, motionOption, markerOption);
|
|
834
|
-
return mapProxy.
|
|
796
|
+
return mapProxy.createNativeMapProxy(polyline, {
|
|
835
797
|
addTo: function(target, map) {
|
|
836
798
|
return target.addTo(generalMapMethods.getMap(map));
|
|
837
799
|
}
|
|
838
800
|
});
|
|
839
801
|
}
|
|
840
802
|
motionSeq(motion, options) {
|
|
841
|
-
const seq = L.motion.seq(
|
|
842
|
-
|
|
803
|
+
const seq = L.motion.seq(
|
|
804
|
+
motion.map((item) => item.getInitLayer?.() || item),
|
|
805
|
+
options
|
|
806
|
+
);
|
|
807
|
+
return mapProxy.createNativeMapProxy(seq, {
|
|
843
808
|
addTo: function(target, map) {
|
|
844
809
|
return target.addTo(generalMapMethods.getMap(map));
|
|
845
810
|
}
|
|
@@ -922,7 +887,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
922
887
|
trackPolyline = null;
|
|
923
888
|
}
|
|
924
889
|
};
|
|
925
|
-
return mapProxy.
|
|
890
|
+
return mapProxy.createNativeMapProxy(marker, handlers);
|
|
926
891
|
}
|
|
927
892
|
// 创建绘画工具 rectangle 正方形 circle 圆形 polygon 多边形
|
|
928
893
|
CreatePm(pmType = "rectangle", options = {}, map) {
|
|
@@ -948,7 +913,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
948
913
|
map.on("pm:create", (e) => {
|
|
949
914
|
layer = e.layer;
|
|
950
915
|
if (options.onChange) {
|
|
951
|
-
const pointsList =
|
|
916
|
+
const pointsList = layer.getLatLngs()[0];
|
|
952
917
|
options.onChange(pointsList);
|
|
953
918
|
}
|
|
954
919
|
});
|
|
@@ -966,7 +931,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
966
931
|
enableDraw(toolType);
|
|
967
932
|
}
|
|
968
933
|
};
|
|
969
|
-
return mapProxy.
|
|
934
|
+
return mapProxy.createNativeMapProxy({}, handlers);
|
|
970
935
|
}
|
|
971
936
|
// 电子围栏
|
|
972
937
|
CreateFence(pmType = "rectangle", options = {}, map) {
|
|
@@ -994,7 +959,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
994
959
|
pm.close();
|
|
995
960
|
};
|
|
996
961
|
const onChange = (pointList) => {
|
|
997
|
-
setPolygon(
|
|
962
|
+
setPolygon(pointList);
|
|
998
963
|
};
|
|
999
964
|
const pm = this.CreatePm(
|
|
1000
965
|
pmType,
|
|
@@ -1014,7 +979,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
1014
979
|
setPolygon(circleToPolygonPoints(lnglat, radius / 2e3));
|
|
1015
980
|
},
|
|
1016
981
|
setPolygon: function(target, pointList) {
|
|
1017
|
-
setPolygon(
|
|
982
|
+
setPolygon(pointList);
|
|
1018
983
|
},
|
|
1019
984
|
startDraw: function(target, toolType = "rectangle") {
|
|
1020
985
|
clearPolygon();
|
|
@@ -1035,7 +1000,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
1035
1000
|
target.setMouseTool(toolType);
|
|
1036
1001
|
}
|
|
1037
1002
|
};
|
|
1038
|
-
return mapProxy.
|
|
1003
|
+
return mapProxy.createNativeMapProxy(pm, handlers);
|
|
1039
1004
|
}
|
|
1040
1005
|
// 测距工具 labelColor labelFillColor lineColor
|
|
1041
1006
|
RangingTool(options = {}, map) {
|
|
@@ -1328,7 +1293,7 @@ class Leafletjs extends events.EventEmitter {
|
|
|
1328
1293
|
rangingPointsEnd = null;
|
|
1329
1294
|
}
|
|
1330
1295
|
};
|
|
1331
|
-
return mapProxy.
|
|
1296
|
+
return mapProxy.createNativeMapProxy({}, handlers);
|
|
1332
1297
|
}
|
|
1333
1298
|
}
|
|
1334
1299
|
|
package/lib/utils/map/index.js
CHANGED
|
@@ -89,11 +89,11 @@ function setMapServer(mapType, mapConfig = {}) {
|
|
|
89
89
|
return promise;
|
|
90
90
|
}
|
|
91
91
|
function setPoiServer(mapConfig) {
|
|
92
|
-
const data = mapConfig;
|
|
93
|
-
data.mapCoordinate = typeof data.bmCorrect === "number" ? data.bmCorrect :
|
|
92
|
+
const data = { ...mapConfig };
|
|
93
|
+
data.mapCoordinate = data.mapCoordinate ?? (typeof data.bmCorrect === "number" ? data.bmCorrect : void 0);
|
|
94
94
|
data.serverCoordinate = 1;
|
|
95
|
-
data.projectCoordinate = 1;
|
|
96
|
-
data.projectPoiCoordinate =
|
|
95
|
+
data.projectCoordinate = data.projectCoordinate ?? 1;
|
|
96
|
+
data.projectPoiCoordinate = data.projectPoiCoordinate ?? data.projectCoordinate;
|
|
97
97
|
data.poiServer = data.poiServer || {};
|
|
98
98
|
let city = data.poiServer.city || "";
|
|
99
99
|
city = city.split("-");
|
|
@@ -2,20 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const nativeTargets = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
const rawGetters = /* @__PURE__ */ new Set(["getInitMap", "getRawMap", "getInitMarker", "getInitLayer"]);
|
|
7
|
+
const unwrapNative = (value) => {
|
|
8
|
+
if (Array.isArray(value)) return value.map(unwrapNative);
|
|
9
|
+
while (value && nativeTargets.has(value)) value = nativeTargets.get(value);
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
12
|
+
const createMapProxy = (target, handlers = {}, nativeMethods = false) => {
|
|
13
|
+
const proxy = new Proxy(target, {
|
|
7
14
|
get(_target, prop) {
|
|
15
|
+
if (nativeMethods && prop === "getInitLayer") return () => unwrapNative(_target);
|
|
8
16
|
if (handlers[prop]) {
|
|
9
|
-
return (...args) =>
|
|
17
|
+
return (...args) => {
|
|
18
|
+
const result = handlers[prop](_target, ...args);
|
|
19
|
+
return nativeMethods && result === _target && !rawGetters.has(prop) ? proxy : result;
|
|
20
|
+
};
|
|
10
21
|
}
|
|
11
|
-
|
|
22
|
+
const value = _target[prop];
|
|
23
|
+
if (!nativeMethods || typeof value !== "function") return value;
|
|
24
|
+
return (...args) => {
|
|
25
|
+
const result = value.apply(_target, args.map(unwrapNative));
|
|
26
|
+
return result === _target && !rawGetters.has(prop) ? proxy : result;
|
|
27
|
+
};
|
|
12
28
|
},
|
|
13
29
|
set(_target, prop, value) {
|
|
14
30
|
if (prop === "_proxy") return true;
|
|
15
31
|
return Reflect.set(_target, prop, value);
|
|
16
32
|
}
|
|
17
33
|
});
|
|
34
|
+
if (nativeMethods) nativeTargets.set(proxy, target);
|
|
35
|
+
return proxy;
|
|
18
36
|
};
|
|
37
|
+
const createNativeMapProxy = (target, handlers = {}) => createMapProxy(target, handlers, true);
|
|
19
38
|
const createWrappedHandlerStore = () => {
|
|
20
39
|
const wrappedHandlerMap = /* @__PURE__ */ new Map();
|
|
21
40
|
return {
|
|
@@ -40,5 +59,6 @@ const createWrappedHandlerStore = () => {
|
|
|
40
59
|
};
|
|
41
60
|
|
|
42
61
|
exports.createMapProxy = createMapProxy;
|
|
62
|
+
exports.createNativeMapProxy = createNativeMapProxy;
|
|
43
63
|
exports.createWrappedHandlerStore = createWrappedHandlerStore;
|
|
44
64
|
exports.default = createMapProxy;
|
package/lib/version.js
CHANGED