@react-native-ohos/react-native-amap3d 3.3.0-rc.1 → 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,6 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use these variables when you tailor your ArkTS code. They must be of the const type.
|
|
3
|
+
*/
|
|
4
|
+
export const HAR_VERSION = '3.3.0-rc.3';
|
|
5
|
+
export const BUILD_MODE_NAME = 'debug';
|
|
6
|
+
export const DEBUG = true;
|
|
7
|
+
export const TARGET_NAME = 'default';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* BuildProfile Class is used only for compatibility purposes.
|
|
11
|
+
*/
|
|
1
12
|
export default class BuildProfile {
|
|
2
|
-
static readonly HAR_VERSION =
|
|
3
|
-
static readonly BUILD_MODE_NAME =
|
|
4
|
-
static readonly DEBUG =
|
|
5
|
-
static readonly TARGET_NAME =
|
|
13
|
+
static readonly HAR_VERSION = HAR_VERSION;
|
|
14
|
+
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
|
|
15
|
+
static readonly DEBUG = DEBUG;
|
|
16
|
+
static readonly TARGET_NAME = TARGET_NAME;
|
|
6
17
|
}
|
|
@@ -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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
//地图
|
|
@@ -443,25 +453,74 @@ export struct AMapView {
|
|
|
443
453
|
let tagName = "";
|
|
444
454
|
let flag = false;
|
|
445
455
|
let flagLine = false;
|
|
456
|
+
let flagCircle = false;
|
|
457
|
+
|
|
458
|
+
// 收集当前所有 Circle 子组件的 tag
|
|
459
|
+
let currentCircleTags: Set<number> = new Set();
|
|
460
|
+
for (let i = 0; i < descriptor.childrenTags.length; i++) {
|
|
461
|
+
let childTagName =
|
|
462
|
+
this.ctx.rnInstance.getComponentNameFromDescriptorType(this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i])?.type);
|
|
463
|
+
if (childTagName === A_MAP_CIRCLE_VIEW_TYPE) {
|
|
464
|
+
currentCircleTags.add(descriptor.childrenTags[i]);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
// 删除不再需要的 Circle(只删除属于当前 MapView 的)
|
|
469
|
+
let circlesToRemove: number[] = [];
|
|
470
|
+
GlobalCache.currentPageCircle.forEach((mapTag: number, circleTag: number) => {
|
|
471
|
+
// 只处理属于当前 MapView 的 Circle
|
|
472
|
+
if (mapTag === this.tag && !currentCircleTags.has(circleTag)) {
|
|
473
|
+
circlesToRemove.push(circleTag);
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
for (let circleTag of circlesToRemove) {
|
|
477
|
+
let circleToRemove = GlobalCache.circleCacheMap.get(circleTag);
|
|
478
|
+
if (circleToRemove) {
|
|
479
|
+
circleToRemove.remove(); // 从地图上移除圆
|
|
480
|
+
}
|
|
481
|
+
GlobalCache.circleCacheMap.remove(circleTag); // 从缓存中删除
|
|
482
|
+
GlobalCache.currentPageCircle.remove(circleTag); // 从映射关系中删除
|
|
483
|
+
}
|
|
484
|
+
|
|
446
485
|
for (let i = 0; i < descriptor.childrenTags.length; i++) {
|
|
447
486
|
tagName =
|
|
448
487
|
this.ctx.rnInstance.getComponentNameFromDescriptorType(this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i])?.type);
|
|
449
488
|
switch (tagName) {
|
|
450
489
|
case A_MAP_CIRCLE_VIEW_TYPE:
|
|
451
|
-
|
|
490
|
+
flagCircle = false;
|
|
452
491
|
let circleProp =
|
|
453
492
|
this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).props as AMapCircleProps;
|
|
454
493
|
let childCircleTag: number = this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).tag;
|
|
455
|
-
|
|
456
|
-
//
|
|
457
|
-
GlobalCache.circleCacheMap.
|
|
458
|
-
if (
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
494
|
+
|
|
495
|
+
// 检查 Circle 是否已存在
|
|
496
|
+
let existingCircle = GlobalCache.circleCacheMap.get(childCircleTag);
|
|
497
|
+
if (existingCircle) {
|
|
498
|
+
// 更新已存在的 Circle 的属性
|
|
499
|
+
flagCircle = true;
|
|
500
|
+
existingCircle.setRadius(circleProp.radius ? circleProp.radius : 5000);
|
|
501
|
+
existingCircle.setCenter(new LatLng(circleProp.center.latitude, circleProp.center.longitude));
|
|
502
|
+
existingCircle.setFillColor(rgbaToHex(circleProp.fillColor ? circleProp.fillColor : "rgba(255, 0, 0, 0.5)"));
|
|
503
|
+
existingCircle.setStrokeColor(rgbaToHex(circleProp.strokeColor ? circleProp.strokeColor :
|
|
463
504
|
"rgba(0, 0, 255, 0.5)"));
|
|
464
|
-
|
|
505
|
+
existingCircle.setStrokeWidth(circleProp.strokeWidth ? circleProp.strokeWidth : 5);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (!flagCircle) {
|
|
509
|
+
// 添加新的 Circle
|
|
510
|
+
let circleOptions = new CircleOptions();
|
|
511
|
+
let circle = this.aMap?.addCircle(circleOptions);
|
|
512
|
+
//Put the overlay ring in the cache and hot-update the properties to modify
|
|
513
|
+
GlobalCache.circleCacheMap.set(childCircleTag, circle);
|
|
514
|
+
// 记录 Circle 与 MapView 的关联关系
|
|
515
|
+
GlobalCache.currentPageCircle.set(childCircleTag, this.tag);
|
|
516
|
+
if (circle) {
|
|
517
|
+
circle.setRadius(circleProp.radius ? circleProp.radius : 5000);
|
|
518
|
+
circle.setCenter(new LatLng(circleProp.center.latitude, circleProp.center.longitude));
|
|
519
|
+
circle.setFillColor(rgbaToHex(circleProp.fillColor ? circleProp.fillColor : "rgba(255, 0, 0, 0.5)"));
|
|
520
|
+
circle.setStrokeColor(rgbaToHex(circleProp.strokeColor ? circleProp.strokeColor :
|
|
521
|
+
"rgba(0, 0, 255, 0.5)"));
|
|
522
|
+
circle.setStrokeWidth(circleProp.strokeWidth ? circleProp.strokeWidth : 5);
|
|
523
|
+
}
|
|
465
524
|
}
|
|
466
525
|
break;
|
|
467
526
|
case A_MAP_POLYGON_TYPE:
|
package/harmony/rn_amap3d.har
CHANGED
|
Binary file
|