@react-native-ohos/react-native-amap3d 3.3.0-rc.3 → 3.3.0-rc.4

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,7 +1,7 @@
1
1
  /**
2
2
  * Use these variables when you tailor your ArkTS code. They must be of the const type.
3
3
  */
4
- export const HAR_VERSION = '3.3.0-rc.3';
4
+ export const HAR_VERSION = '3.3.0-rc.4';
5
5
  export const BUILD_MODE_NAME = 'debug';
6
6
  export const DEBUG = true;
7
7
  export const TARGET_NAME = 'default';
@@ -3,7 +3,7 @@
3
3
  "devDependencies": {
4
4
  },
5
5
  "name": "@react-native-ohos/react-native-amap3d",
6
- "version": "3.3.0-rc.3",
6
+ "version": "3.3.0-rc.4",
7
7
  "description": "Please describe the basic information.",
8
8
  "main": "index.ets",
9
9
  "author": "",
@@ -90,6 +90,11 @@ export struct AMapCircle {
90
90
  }
91
91
  )
92
92
  }
93
+
94
+ aboutToDisappear(): void {
95
+ this.unregisterDescriptorChangesListener?.();
96
+ }
97
+
93
98
  build() {
94
99
  }
95
100
  }
@@ -77,6 +77,11 @@ export struct AMapMarker {
77
77
  )
78
78
  }
79
79
 
80
+ aboutToDisappear(): void {
81
+ // 取消订阅
82
+ this.unregisterDescriptorChangesListener?.();
83
+ }
84
+
80
85
  build() {
81
86
  ContentSlot(this.ctx.getContentForTag(this.tag))
82
87
  }
@@ -127,6 +127,16 @@ export struct AMapView {
127
127
  GlobalCache.circleCacheMap.remove(circleTag);
128
128
  GlobalCache.currentPageCircle.remove(circleTag);
129
129
  }
130
+ // 清理属于当前 MapView 的 Marker
131
+ let markerTagsToRemove: number[] = [];
132
+ GlobalCache.currentPageMarker.forEach((mapTag: number, markerTag: number) => {
133
+ if (mapTag === this.tag) {
134
+ markerTagsToRemove.push(markerTag);
135
+ }
136
+ });
137
+ for (let markerTag of markerTagsToRemove) {
138
+ GlobalCache.currentPageMarker.remove(markerTag);
139
+ }
130
140
  }
131
141
 
132
142
  //地图
@@ -457,11 +467,15 @@ export struct AMapView {
457
467
 
458
468
  // 收集当前所有 Circle 子组件的 tag
459
469
  let currentCircleTags: Set<number> = new Set();
470
+ // 收集当前所有 Marker 子组件的 tag
471
+ let currentMarkerTags: Set<number> = new Set();
460
472
  for (let i = 0; i < descriptor.childrenTags.length; i++) {
461
473
  let childTagName =
462
474
  this.ctx.rnInstance.getComponentNameFromDescriptorType(this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i])?.type);
463
475
  if (childTagName === A_MAP_CIRCLE_VIEW_TYPE) {
464
476
  currentCircleTags.add(descriptor.childrenTags[i]);
477
+ } else if (childTagName === A_MAP_MARKER_TYPE) {
478
+ currentMarkerTags.add(descriptor.childrenTags[i]);
465
479
  }
466
480
  }
467
481
 
@@ -482,6 +496,50 @@ export struct AMapView {
482
496
  GlobalCache.currentPageCircle.remove(circleTag); // 从映射关系中删除
483
497
  }
484
498
 
499
+ // 删除不再需要的 Marker(只删除属于当前 MapView 的)
500
+ let markersToRemove: number[] = [];
501
+ GlobalCache.currentPageMarker.forEach((mapTag: number, markerTag: number) => {
502
+ // 只处理属于当前 MapView 的 Marker
503
+ if (mapTag === this.tag && !currentMarkerTags.has(markerTag)) {
504
+ markersToRemove.push(markerTag);
505
+ }
506
+ });
507
+
508
+ // 删除 Marker
509
+ let markers = GlobalCache.mapMarker.get(this.tag) ?? [];
510
+ let markerTagAndDescriptorTagArray = GlobalCache.markerTagAndDescriptorTag.get(this.tag) ?? [];
511
+
512
+ for (let markerTag of markersToRemove) {
513
+ // 从地图上移除 Marker
514
+ for (let index = 0; index < markerTagAndDescriptorTagArray.length; index++) {
515
+ markerTagAndDescriptorTagArray[index].forEach((markerID: string, tag: number) => {
516
+ if (tag === markerTag) {
517
+ // 找到对应的 Marker 并移除
518
+ for (let markerIndex = 0; markerIndex < markers.length; markerIndex++) {
519
+ if (markers[markerIndex].getId() === markerID) {
520
+ markers[markerIndex].remove(); // 从地图上移除 Marker
521
+ markers.splice(markerIndex, 1); // 从数组中删除
522
+ break;
523
+ }
524
+ }
525
+ markerTagAndDescriptorTagArray.splice(index, 1); // 从映射关系中删除
526
+ }
527
+ });
528
+ }
529
+ GlobalCache.currentPageMarker.remove(markerTag); // 从映射关系中删除
530
+ // 从 markerTag 数组中删除
531
+ let markerTagIndex = this.markerTag.indexOf(markerTag);
532
+ if (markerTagIndex !== -1) {
533
+ this.markerTag.splice(markerTagIndex, 1);
534
+ }
535
+ }
536
+
537
+ // 更新缓存
538
+ GlobalCache.mapMarker.set(this.tag, markers);
539
+ GlobalCache.markerTagAndDescriptorTag.set(this.tag, markerTagAndDescriptorTagArray);
540
+ this.markers = markers;
541
+ this.markerTagAndDescriptorTagArray = markerTagAndDescriptorTagArray;
542
+
485
543
  for (let i = 0; i < descriptor.childrenTags.length; i++) {
486
544
  tagName =
487
545
  this.ctx.rnInstance.getComponentNameFromDescriptorType(this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i])?.type);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-ohos/react-native-amap3d",
3
- "version": "3.3.0-rc.3",
3
+ "version": "3.3.0-rc.4",
4
4
  "description": "react-native 高德地图组件,支持 harmonyOS",
5
5
  "license": "MIT",
6
6
  "keywords": [