@react-native-ohos/react-native-amap3d 3.3.0-rc.2 → 3.3.0-rc.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.
@@ -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.2';
4
+ export const HAR_VERSION = '3.3.0-rc.3';
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.2",
6
+ "version": "3.3.0-rc.3",
7
7
  "description": "Please describe the basic information.",
8
8
  "main": "index.ets",
9
9
  "author": "",
@@ -6,6 +6,10 @@ import HashMap from '@ohos.util.HashMap';
6
6
  export default class GlobalCache {
7
7
  public static index: number = 1
8
8
  public static isGO: boolean = false;
9
+ // 记录已销毁的地图组件tag,用于防止异步操作访问已释放资源
10
+ public static destroyedMapTags: Set<number> = new Set();
11
+ // 记录已销毁的Marker组件tag
12
+ public static destroyedMarkerTags: Set<number> = new Set();
9
13
  public static cacheMap: Map<Object | undefined, number> = new Map()
10
14
  public static cacheMapPageDestroy: Map<number, boolean> = new Map()
11
15
  public static mapMarker: Map<number, Array<Marker>> = new Map();//map的tag和 marker集合
@@ -21,4 +25,8 @@ export default class GlobalCache {
21
25
 
22
26
  public static polygonCacheMap: HashMap<number, Polygon> = new HashMap();
23
27
  public static circleCacheMap: HashMap<number, Circle> = new HashMap();
28
+ // 新增: map的tag和circle集合的映射关系
29
+ public static mapCircle: Map<number, Array<Circle>> = new Map();
30
+ // 新增: circle的tag和map的tag的映射关系
31
+ public static currentPageCircle: HashMap<number, number> = new HashMap();
24
32
  }
@@ -109,14 +109,24 @@ export struct AMapView {
109
109
  }
110
110
  this.unregisterDescriptorChangesListener?.()
111
111
  this.cleanupCallback?.()
112
- GlobalCache.maps.get(this.tag)?.clear()
113
- GlobalCache.mapViews.get(this.tag)?.onDestroy();
114
- GlobalCache.mapMarker.delete(this.tag);
115
- GlobalCache.markerTagAndDescriptorTag.delete(this.tag);
116
- GlobalCache.mapPolyLine.delete(this.tag);
117
- GlobalCache.polyLinesTagAndDescriptorTag.delete(this.tag);
118
- GlobalCache.polygonCacheMap.clear();
119
- GlobalCache.circleCacheMap.clear();
112
+ GlobalCache.maps.get(this.tag)?.clear()
113
+ GlobalCache.mapViews.get(this.tag)?.onDestroy();
114
+ GlobalCache.mapMarker.delete(this.tag);
115
+ GlobalCache.markerTagAndDescriptorTag.delete(this.tag);
116
+ GlobalCache.mapPolyLine.delete(this.tag);
117
+ GlobalCache.polyLinesTagAndDescriptorTag.delete(this.tag);
118
+ GlobalCache.polygonCacheMap.clear();
119
+ // 清理属于当前 MapView 的 Circle
120
+ let circleTagsToRemove: number[] = [];
121
+ GlobalCache.currentPageCircle.forEach((mapTag: number, circleTag: number) => {
122
+ if (mapTag === this.tag) {
123
+ circleTagsToRemove.push(circleTag);
124
+ }
125
+ });
126
+ for (let circleTag of circleTagsToRemove) {
127
+ GlobalCache.circleCacheMap.remove(circleTag);
128
+ GlobalCache.currentPageCircle.remove(circleTag);
129
+ }
120
130
  }
121
131
 
122
132
  //地图
@@ -455,13 +465,12 @@ export struct AMapView {
455
465
  }
456
466
  }
457
467
 
458
- // 删除不再需要的 Circle
468
+ // 删除不再需要的 Circle(只删除属于当前 MapView 的)
459
469
  let circlesToRemove: number[] = [];
460
- GlobalCache.circleCacheMap.forEach((circle, circleTag) => {
461
- if (circleTag != undefined) {
462
- if (!currentCircleTags.has(circleTag)) {
463
- circlesToRemove.push(circleTag);
464
- }
470
+ GlobalCache.currentPageCircle.forEach((mapTag: number, circleTag: number) => {
471
+ // 只处理属于当前 MapView Circle
472
+ if (mapTag === this.tag && !currentCircleTags.has(circleTag)) {
473
+ circlesToRemove.push(circleTag);
465
474
  }
466
475
  });
467
476
  for (let circleTag of circlesToRemove) {
@@ -470,6 +479,7 @@ export struct AMapView {
470
479
  circleToRemove.remove(); // 从地图上移除圆
471
480
  }
472
481
  GlobalCache.circleCacheMap.remove(circleTag); // 从缓存中删除
482
+ GlobalCache.currentPageCircle.remove(circleTag); // 从映射关系中删除
473
483
  }
474
484
 
475
485
  for (let i = 0; i < descriptor.childrenTags.length; i++) {
@@ -501,6 +511,8 @@ export struct AMapView {
501
511
  let circle = this.aMap?.addCircle(circleOptions);
502
512
  //Put the overlay ring in the cache and hot-update the properties to modify
503
513
  GlobalCache.circleCacheMap.set(childCircleTag, circle);
514
+ // 记录 Circle 与 MapView 的关联关系
515
+ GlobalCache.currentPageCircle.set(childCircleTag, this.tag);
504
516
  if (circle) {
505
517
  circle.setRadius(circleProp.radius ? circleProp.radius : 5000);
506
518
  circle.setCenter(new LatLng(circleProp.center.latitude, circleProp.center.longitude));
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.2",
3
+ "version": "3.3.0-rc.3",
4
4
  "description": "react-native 高德地图组件,支持 harmonyOS",
5
5
  "license": "MIT",
6
6
  "keywords": [