@react-native-ohos/react-native-amap3d 3.2.5-rc.1 → 3.3.0-rc.2

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.2';
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.2.4-0.0.8';
3
- static readonly BUILD_MODE_NAME = 'debug';
4
- static readonly DEBUG = true;
5
- static readonly TARGET_NAME = 'default';
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
  }
@@ -3,7 +3,7 @@
3
3
  "devDependencies": {
4
4
  },
5
5
  "name": "@react-native-ohos/react-native-amap3d",
6
- "version": "3.2.5-rc.1",
6
+ "version": "3.3.0-rc.2",
7
7
  "description": "Please describe the basic information.",
8
8
  "main": "index.ets",
9
9
  "author": "",
@@ -443,25 +443,72 @@ export struct AMapView {
443
443
  let tagName = "";
444
444
  let flag = false;
445
445
  let flagLine = false;
446
+ let flagCircle = false;
447
+
448
+ // 收集当前所有 Circle 子组件的 tag
449
+ let currentCircleTags: Set<number> = new Set();
450
+ for (let i = 0; i < descriptor.childrenTags.length; i++) {
451
+ let childTagName =
452
+ this.ctx.rnInstance.getComponentNameFromDescriptorType(this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i])?.type);
453
+ if (childTagName === A_MAP_CIRCLE_VIEW_TYPE) {
454
+ currentCircleTags.add(descriptor.childrenTags[i]);
455
+ }
456
+ }
457
+
458
+ // 删除不再需要的 Circle
459
+ let circlesToRemove: number[] = [];
460
+ GlobalCache.circleCacheMap.forEach((circle, circleTag) => {
461
+ if (circleTag != undefined) {
462
+ if (!currentCircleTags.has(circleTag)) {
463
+ circlesToRemove.push(circleTag);
464
+ }
465
+ }
466
+ });
467
+ for (let circleTag of circlesToRemove) {
468
+ let circleToRemove = GlobalCache.circleCacheMap.get(circleTag);
469
+ if (circleToRemove) {
470
+ circleToRemove.remove(); // 从地图上移除圆
471
+ }
472
+ GlobalCache.circleCacheMap.remove(circleTag); // 从缓存中删除
473
+ }
474
+
446
475
  for (let i = 0; i < descriptor.childrenTags.length; i++) {
447
476
  tagName =
448
477
  this.ctx.rnInstance.getComponentNameFromDescriptorType(this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i])?.type);
449
478
  switch (tagName) {
450
479
  case A_MAP_CIRCLE_VIEW_TYPE:
451
- let circleOptions = new CircleOptions();
480
+ flagCircle = false;
452
481
  let circleProp =
453
482
  this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).props as AMapCircleProps;
454
483
  let childCircleTag: number = this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).tag;
455
- let circle = this.aMap?.addCircle(circleOptions);
456
- //Put the overlay ring in the cache and hot-update the properties to modify
457
- GlobalCache.circleCacheMap.set(childCircleTag, circle);
458
- if (circle) {
459
- circle.setRadius(circleProp.radius ? circleProp.radius : 5000);
460
- circle.setCenter(new LatLng(circleProp.center.latitude, circleProp.center.longitude));
461
- circle.setFillColor(rgbaToHex(circleProp.fillColor ? circleProp.fillColor : "rgba(255, 0, 0, 0.5)"));
462
- circle.setStrokeColor(rgbaToHex(circleProp.strokeColor ? circleProp.strokeColor :
484
+
485
+ // 检查 Circle 是否已存在
486
+ let existingCircle = GlobalCache.circleCacheMap.get(childCircleTag);
487
+ if (existingCircle) {
488
+ // 更新已存在的 Circle 的属性
489
+ flagCircle = true;
490
+ existingCircle.setRadius(circleProp.radius ? circleProp.radius : 5000);
491
+ existingCircle.setCenter(new LatLng(circleProp.center.latitude, circleProp.center.longitude));
492
+ existingCircle.setFillColor(rgbaToHex(circleProp.fillColor ? circleProp.fillColor : "rgba(255, 0, 0, 0.5)"));
493
+ existingCircle.setStrokeColor(rgbaToHex(circleProp.strokeColor ? circleProp.strokeColor :
463
494
  "rgba(0, 0, 255, 0.5)"));
464
- circle.setStrokeWidth(circleProp.strokeWidth ? circleProp.strokeWidth : 5);
495
+ existingCircle.setStrokeWidth(circleProp.strokeWidth ? circleProp.strokeWidth : 5);
496
+ }
497
+
498
+ if (!flagCircle) {
499
+ // 添加新的 Circle
500
+ let circleOptions = new CircleOptions();
501
+ let circle = this.aMap?.addCircle(circleOptions);
502
+ //Put the overlay ring in the cache and hot-update the properties to modify
503
+ GlobalCache.circleCacheMap.set(childCircleTag, circle);
504
+ if (circle) {
505
+ circle.setRadius(circleProp.radius ? circleProp.radius : 5000);
506
+ circle.setCenter(new LatLng(circleProp.center.latitude, circleProp.center.longitude));
507
+ circle.setFillColor(rgbaToHex(circleProp.fillColor ? circleProp.fillColor : "rgba(255, 0, 0, 0.5)"));
508
+ circle.setStrokeColor(rgbaToHex(circleProp.strokeColor ? circleProp.strokeColor :
509
+ "rgba(0, 0, 255, 0.5)"));
510
+ circle.setStrokeWidth(circleProp.strokeWidth ? circleProp.strokeWidth : 5);
511
+ }
465
512
  }
466
513
  break;
467
514
  case A_MAP_POLYGON_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.2.5-rc.1",
3
+ "version": "3.3.0-rc.2",
4
4
  "description": "react-native 高德地图组件,支持 harmonyOS",
5
5
  "license": "MIT",
6
6
  "keywords": [