@react-native-ohos/react-native-amap3d 3.2.5-rc.1 → 3.2.6-rc.1
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/README.md +1 -1
- package/harmony/rn_amap3d/index.ets +2 -0
- package/harmony/rn_amap3d/obfuscation-rules.txt +5 -1
- package/harmony/rn_amap3d/oh-package.json5 +5 -4
- package/harmony/rn_amap3d/src/main/cpp/AMap3dEventEmitRequestHandler.h +105 -94
- package/harmony/rn_amap3d/src/main/cpp/AMapEventEmitters.cpp +22 -12
- package/harmony/rn_amap3d/src/main/cpp/AMapEventEmitters.h +4 -1
- package/harmony/rn_amap3d/src/main/cpp/MapViewJSIBinder.h +40 -20
- package/harmony/rn_amap3d/src/main/cpp/MapViewPackage.h +6 -3
- package/harmony/rn_amap3d/src/main/cpp/Props.cpp +5 -5
- package/harmony/rn_amap3d/src/main/cpp/Props.h +14 -11
- package/harmony/rn_amap3d/src/main/cpp/ShadowNodes.cpp +7 -7
- package/harmony/rn_amap3d/src/main/cpp/ShadowNodes.h +14 -14
- package/harmony/rn_amap3d/src/main/ets/AMap3DModule.ts +52 -4
- package/harmony/rn_amap3d/src/main/ets/{AMap3DPackage.ts → AMap3DPackage.ets} +40 -9
- package/harmony/rn_amap3d/src/main/ets/DownloadIcon.ets +172 -0
- package/harmony/rn_amap3d/src/main/ets/View/AMapCircle.ets +2 -2
- package/harmony/rn_amap3d/src/main/ets/View/AMapMarker.ets +2 -2
- package/harmony/rn_amap3d/src/main/ets/View/AMapPolygon.ets +4 -2
- package/harmony/rn_amap3d/src/main/ets/View/AMapPolyline.ets +2 -2
- package/harmony/rn_amap3d/src/main/ets/View/MapView.ets +138 -61
- package/harmony/rn_amap3d/{ts.ts → ts.ets} +1 -1
- package/harmony/rn_amap3d.har +0 -0
- package/lib/src/map-view.tsx +2 -2
- package/lib/src/{map-viewNativeComponent.ts → map-viewNativeComponent.tsx} +6 -11
- package/package.json +10 -4
- package/harmony/rn_amap3d/BuildProfile.ets +0 -6
- /package/lib/src/{circleNativeComponent.ts → circleNativeComponent.tsx} +0 -0
- /package/lib/src/{heat-mapNativeComponent.ts → heat-mapNativeComponent.tsx} +0 -0
- /package/lib/src/{markerNativeComponent.ts → markerNativeComponent.tsx} +0 -0
- /package/lib/src/{multi-pointNativeComponent.ts → multi-pointNativeComponent.tsx} +0 -0
- /package/lib/src/{polygonNativeComponent.ts → polygonNativeComponent.tsx} +0 -0
- /package/lib/src/{polylineNativeComponent.ts → polylineNativeComponent.tsx} +0 -0
|
@@ -13,10 +13,13 @@ import {
|
|
|
13
13
|
MarkerOptions,
|
|
14
14
|
OnCameraChangeListener,
|
|
15
15
|
OnMarkerDragListener,
|
|
16
|
+
OnLocationChangedListener,
|
|
16
17
|
Poi,
|
|
17
18
|
PolygonOptions,
|
|
18
19
|
Polyline,
|
|
19
|
-
PolylineOptions
|
|
20
|
+
PolylineOptions,
|
|
21
|
+
MyLocationStyle,
|
|
22
|
+
LocationSource
|
|
20
23
|
} from '@amap/amap_lbs_map3d';
|
|
21
24
|
|
|
22
25
|
import { Descriptor, RNComponentContext, RNOHContext, RNViewBase, ViewBaseProps } from '@rnoh/react-native-openharmony';
|
|
@@ -26,8 +29,15 @@ import { A_MAP_POLYLINE_TYPE, AMapPolylineProps } from './AMapPolyline';
|
|
|
26
29
|
import { A_MAP_MARKER_TYPE, AMapMarkerProps } from './AMapMarker';
|
|
27
30
|
|
|
28
31
|
import Logger from '../Logger';
|
|
29
|
-
import { ArrayList, HashMap } from '@kit.ArkTS';
|
|
32
|
+
import { ArrayList, HashMap, JSON } from '@kit.ArkTS';
|
|
30
33
|
import GlobalCache from '../GlobalCache';
|
|
34
|
+
import { application } from '@kit.AbilityKit';
|
|
35
|
+
import { BusinessError } from '@kit.BasicServicesKit';
|
|
36
|
+
import geoLocationManager from '@ohos.geoLocationManager';
|
|
37
|
+
import {
|
|
38
|
+
AMapLocationManagerImpl,
|
|
39
|
+
AMapLocationOption, AMapLocationReGeocodeLanguage, AMapLocationType, IAMapLocationListener } from '@amap/amap_lbs_location';
|
|
40
|
+
import { DownloadIcon } from '../DownloadIcon';
|
|
31
41
|
|
|
32
42
|
export interface MapViewProps extends ViewBaseProps {
|
|
33
43
|
initialCameraPosition?: CameraPosition;
|
|
@@ -55,7 +65,7 @@ const MAP_SHOW_FUNC = 'AMapView';
|
|
|
55
65
|
|
|
56
66
|
export const GOADE_MAP_VIEW_TYPE: string = "AMapView"
|
|
57
67
|
|
|
58
|
-
export type GDMapViewDescriptor = Descriptor<"AMapView", MapViewProps>;
|
|
68
|
+
export type GDMapViewDescriptor = Descriptor<"AMapView", '', '', MapViewProps>;
|
|
59
69
|
|
|
60
70
|
export let globalContext: Context;
|
|
61
71
|
|
|
@@ -69,13 +79,14 @@ export struct AMapView {
|
|
|
69
79
|
polyLineTag: Array<number> = []
|
|
70
80
|
markerTag: Array<number> = []
|
|
71
81
|
@State gDMapDescriptor: GDMapViewDescriptor = {} as GDMapViewDescriptor
|
|
82
|
+
private intervalId: number = 0;
|
|
72
83
|
private unregisterDescriptorChangesListener?: () => void = undefined
|
|
73
84
|
private cleanupCallback?: () => void = undefined;
|
|
74
85
|
private markers : Array<Marker> = new Array();
|
|
75
86
|
private polylines : Array<Polyline> = new Array();
|
|
76
87
|
private markerTagAndDescriptorTagArray : Array<HashMap<number, string>> = new Array();
|
|
77
88
|
private polylineTagAndDescriptorTagArray : Array<HashMap<number, string>> = new Array();
|
|
78
|
-
|
|
89
|
+
private mapListener?: OnLocationChangedListener;
|
|
79
90
|
aboutToAppear(): void {
|
|
80
91
|
this.cleanupCallback = this.ctx.componentCommandReceiver.registerCommandCallback(
|
|
81
92
|
this.tag,
|
|
@@ -84,7 +95,7 @@ export struct AMapView {
|
|
|
84
95
|
this.aMap?.animateCamera(CameraUpdateFactory.newCameraPosition(args[0]), null, args[1]);
|
|
85
96
|
}
|
|
86
97
|
});
|
|
87
|
-
globalContext =
|
|
98
|
+
globalContext = application.getApplicationContext();
|
|
88
99
|
this.gDMapDescriptor = this.ctx.descriptorRegistry.getDescriptor<GDMapViewDescriptor>(this.tag);
|
|
89
100
|
// GlobalCache.markerProp = new HashMap();
|
|
90
101
|
this.getProp(this.gDMapDescriptor);
|
|
@@ -95,7 +106,17 @@ export struct AMapView {
|
|
|
95
106
|
GlobalCache.mapPolyLine.clear();
|
|
96
107
|
/*------ 当RN侧属性props有更改 -------*/
|
|
97
108
|
this.gDMapDescriptor = (newDescriptor as GDMapViewDescriptor)
|
|
109
|
+
let oldMyLocationEnabled = this.myLocationEnabled;
|
|
98
110
|
this.getProp(this.gDMapDescriptor);
|
|
111
|
+
if (oldMyLocationEnabled !== this.myLocationEnabled) {
|
|
112
|
+
this.aMap.setMyLocationEnabled(this.myLocationEnabled);
|
|
113
|
+
if (this.myLocationEnabled) {
|
|
114
|
+
this.startLocationUpdates();
|
|
115
|
+
} else {
|
|
116
|
+
this.stopLocationUpdates();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
99
120
|
this.getOverlay(this.gDMapDescriptor);
|
|
100
121
|
}
|
|
101
122
|
|
|
@@ -119,7 +140,8 @@ export struct AMapView {
|
|
|
119
140
|
GlobalCache.circleCacheMap.clear();
|
|
120
141
|
}
|
|
121
142
|
|
|
122
|
-
|
|
143
|
+
locationManager?:AMapLocationManagerImpl
|
|
144
|
+
private locationStyle: MyLocationStyle = new MyLocationStyle();
|
|
123
145
|
private mapView?: MapView;
|
|
124
146
|
private aMap?: AMap;
|
|
125
147
|
mapType: number = 1;
|
|
@@ -234,13 +256,15 @@ export struct AMapView {
|
|
|
234
256
|
mapview.onCreate();
|
|
235
257
|
GlobalCache.mapViews.set(this.tag, mapview);
|
|
236
258
|
this.mapView = GlobalCache.mapViews.get(this.tag);
|
|
237
|
-
this.mapView.getMapAsync((map:AMap) => {
|
|
259
|
+
this.mapView.getMapAsync(async (map: AMap) => {
|
|
238
260
|
GlobalCache.maps.set(this.tag, map);
|
|
239
261
|
this.aMap = GlobalCache.maps.get(this.tag);
|
|
262
|
+
this.aMap.setLocationSource(this);
|
|
240
263
|
this.getOverlay(this.gDMapDescriptor);
|
|
241
264
|
if (this.initialCameraPosition != null) {
|
|
242
265
|
this.aMap?.moveCamera(CameraUpdateFactory.newCameraPosition(this.initialCameraPosition));
|
|
243
266
|
}
|
|
267
|
+
|
|
244
268
|
this.aMap?.setOnMapClickListener((point: LatLng) => {
|
|
245
269
|
this.onClickFunction(point)
|
|
246
270
|
});
|
|
@@ -270,6 +294,7 @@ export struct AMapView {
|
|
|
270
294
|
// 注:只有在有室内地图显示的情况下最大级别为20,否则最大级别为19。
|
|
271
295
|
this.aMap.setMinZoomLevel(this.minZoom);
|
|
272
296
|
this.aMap.setMaxZoomLevel(this.maxZoom);
|
|
297
|
+
this.aMap.setLocationSource(this);
|
|
273
298
|
this.aMap.setMyLocationEnabled(this.myLocationEnabled);
|
|
274
299
|
//设置最小缩放级别 缩放级别范围为[3, 20],超出范围将按最小级别计算
|
|
275
300
|
this.aMap.showBuildings(this.buildingsEnabled);
|
|
@@ -283,8 +308,16 @@ export struct AMapView {
|
|
|
283
308
|
uiSettings?.setCompassEnabled(this.compassEnabled);
|
|
284
309
|
uiSettings?.setMyLocationButtonEnabled(this.myLocationButtonEnabled);
|
|
285
310
|
uiSettings?.setZoomControlsEnabled(this.zoomControlsEnabled);
|
|
286
|
-
|
|
287
311
|
this.onLoadFunction();
|
|
312
|
+
if (this.myLocationEnabled) {
|
|
313
|
+
setTimeout(() => {
|
|
314
|
+
if (this.aMap) {
|
|
315
|
+
const targetType = MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER;
|
|
316
|
+
this.locationStyle.myLocationType(targetType);
|
|
317
|
+
this.aMap.setMyLocationStyle(this.locationStyle);
|
|
318
|
+
}
|
|
319
|
+
},50);
|
|
320
|
+
}
|
|
288
321
|
this.aMap?.setOnPolylineClickListener((polyLine: Polyline): void => {
|
|
289
322
|
let len: number | undefined = GlobalCache.mapPolyLine.get(this.tag)?.length;
|
|
290
323
|
let polyLinesArray: Array<Polyline> | undefined = GlobalCache.mapPolyLine.get(this.tag);
|
|
@@ -351,8 +384,7 @@ export struct AMapView {
|
|
|
351
384
|
}
|
|
352
385
|
}
|
|
353
386
|
}
|
|
354
|
-
})
|
|
355
|
-
)
|
|
387
|
+
}))
|
|
356
388
|
})
|
|
357
389
|
}
|
|
358
390
|
|
|
@@ -364,78 +396,78 @@ export struct AMapView {
|
|
|
364
396
|
* 获取rn侧传递多来的prop
|
|
365
397
|
*/
|
|
366
398
|
private getProp(descriptor: GDMapViewDescriptor) {
|
|
367
|
-
this.mapType = descriptor.
|
|
399
|
+
this.mapType = descriptor.rawProps.mapType;
|
|
368
400
|
//初始位置
|
|
369
|
-
if (descriptor.
|
|
370
|
-
this.initialCameraPosition = descriptor.
|
|
401
|
+
if (descriptor.rawProps.initialCameraPosition != null) {
|
|
402
|
+
this.initialCameraPosition = descriptor.rawProps.initialCameraPosition;
|
|
371
403
|
}
|
|
372
404
|
//是否显示当前定位
|
|
373
|
-
if (descriptor.
|
|
374
|
-
this.myLocationEnabled = descriptor.
|
|
405
|
+
if (descriptor.rawProps.myLocationEnabled != null) {
|
|
406
|
+
this.myLocationEnabled = descriptor.rawProps.myLocationEnabled;
|
|
375
407
|
}
|
|
376
408
|
//是否显示室内地图
|
|
377
|
-
if (descriptor.
|
|
378
|
-
this.indoorViewEnabled = descriptor.
|
|
409
|
+
if (descriptor.rawProps.indoorViewEnabled != null) {
|
|
410
|
+
this.indoorViewEnabled = descriptor.rawProps.indoorViewEnabled;
|
|
379
411
|
}
|
|
380
412
|
//是否显示3D建筑
|
|
381
|
-
if (descriptor.
|
|
382
|
-
this.buildingsEnabled = descriptor.
|
|
413
|
+
if (descriptor.rawProps.buildingsEnabled != null) {
|
|
414
|
+
this.buildingsEnabled = descriptor.rawProps.buildingsEnabled;
|
|
383
415
|
}
|
|
384
416
|
//是否显示标注
|
|
385
|
-
if (descriptor.
|
|
386
|
-
this.labelsEnabled = descriptor.
|
|
417
|
+
if (descriptor.rawProps.labelsEnabled != null) {
|
|
418
|
+
this.labelsEnabled = descriptor.rawProps.labelsEnabled;
|
|
387
419
|
}
|
|
388
420
|
//是否显示指南针
|
|
389
|
-
if (descriptor.
|
|
390
|
-
this.compassEnabled = descriptor.
|
|
421
|
+
if (descriptor.rawProps.compassEnabled != null) {
|
|
422
|
+
this.compassEnabled = descriptor.rawProps.compassEnabled;
|
|
391
423
|
}
|
|
392
424
|
//是否显示放大缩小按钮
|
|
393
|
-
if (descriptor.
|
|
394
|
-
this.zoomControlsEnabled = descriptor.
|
|
425
|
+
if (descriptor.rawProps.zoomControlsEnabled != null) {
|
|
426
|
+
this.zoomControlsEnabled = descriptor.rawProps.zoomControlsEnabled;
|
|
395
427
|
}
|
|
396
428
|
|
|
397
|
-
if (descriptor.
|
|
398
|
-
this.myLocationButtonEnabled = descriptor.
|
|
429
|
+
if (descriptor.rawProps.myLocationButtonEnabled != null) {
|
|
430
|
+
this.myLocationButtonEnabled = descriptor.rawProps.myLocationButtonEnabled;
|
|
399
431
|
}
|
|
400
432
|
//是否显示比例尺
|
|
401
|
-
if (descriptor.
|
|
402
|
-
this.scaleControlsEnabled = descriptor.
|
|
433
|
+
if (descriptor.rawProps.scaleControlsEnabled != null) {
|
|
434
|
+
this.scaleControlsEnabled = descriptor.rawProps.scaleControlsEnabled;
|
|
403
435
|
}
|
|
404
436
|
//是否显示路况
|
|
405
|
-
if (descriptor.
|
|
406
|
-
this.trafficEnabled = descriptor.
|
|
437
|
+
if (descriptor.rawProps.trafficEnabled != null) {
|
|
438
|
+
this.trafficEnabled = descriptor.rawProps.trafficEnabled;
|
|
407
439
|
}
|
|
408
440
|
//最大缩放级别
|
|
409
|
-
if (descriptor.
|
|
410
|
-
this.maxZoom = descriptor.
|
|
441
|
+
if (descriptor.rawProps.maxZoom != null) {
|
|
442
|
+
this.maxZoom = descriptor.rawProps.maxZoom;
|
|
411
443
|
}
|
|
412
444
|
//最小缩放级别
|
|
413
|
-
if (descriptor.
|
|
414
|
-
this.minZoom = descriptor.
|
|
445
|
+
if (descriptor.rawProps.minZoom != null) {
|
|
446
|
+
this.minZoom = descriptor.rawProps.minZoom;
|
|
415
447
|
}
|
|
416
448
|
//是否启用缩放手势,用于放大缩小
|
|
417
|
-
if (descriptor.
|
|
418
|
-
this.zoomGesturesEnabled = descriptor.
|
|
449
|
+
if (descriptor.rawProps.zoomGesturesEnabled != null) {
|
|
450
|
+
this.zoomGesturesEnabled = descriptor.rawProps.zoomGesturesEnabled;
|
|
419
451
|
}
|
|
420
452
|
//是否启用滑动手势,用于平移
|
|
421
|
-
if (descriptor.
|
|
422
|
-
this.scrollGesturesEnabled = descriptor.
|
|
453
|
+
if (descriptor.rawProps.scrollGesturesEnabled != null) {
|
|
454
|
+
this.scrollGesturesEnabled = descriptor.rawProps.scrollGesturesEnabled;
|
|
423
455
|
}
|
|
424
456
|
//是否启用旋转手势,用于调整方向
|
|
425
|
-
if (descriptor.
|
|
426
|
-
this.rotateGesturesEnabled = descriptor.
|
|
457
|
+
if (descriptor.rawProps.rotateGesturesEnabled != null) {
|
|
458
|
+
this.rotateGesturesEnabled = descriptor.rawProps.rotateGesturesEnabled;
|
|
427
459
|
}
|
|
428
460
|
//是否启用倾斜手势,用于改变视角
|
|
429
|
-
if (descriptor.
|
|
430
|
-
this.tiltGesturesEnabled = descriptor.
|
|
461
|
+
if (descriptor.rawProps.tiltGesturesEnabled != null) {
|
|
462
|
+
this.tiltGesturesEnabled = descriptor.rawProps.tiltGesturesEnabled;
|
|
431
463
|
}
|
|
432
464
|
//设定定位的最小更新距离 @platform ios
|
|
433
|
-
if (descriptor.
|
|
434
|
-
this.distanceFilter = descriptor.
|
|
465
|
+
if (descriptor.rawProps.distanceFilter != null) {
|
|
466
|
+
this.distanceFilter = descriptor.rawProps.distanceFilter;
|
|
435
467
|
}
|
|
436
468
|
//设定最小更新角度,默认为 1 度 @platform ios
|
|
437
|
-
if (descriptor.
|
|
438
|
-
this.headingFilter = descriptor.
|
|
469
|
+
if (descriptor.rawProps.headingFilter != null) {
|
|
470
|
+
this.headingFilter = descriptor.rawProps.headingFilter;
|
|
439
471
|
}
|
|
440
472
|
}
|
|
441
473
|
|
|
@@ -450,7 +482,7 @@ export struct AMapView {
|
|
|
450
482
|
case A_MAP_CIRCLE_VIEW_TYPE:
|
|
451
483
|
let circleOptions = new CircleOptions();
|
|
452
484
|
let circleProp =
|
|
453
|
-
this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).
|
|
485
|
+
this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).rawProps as AMapCircleProps;
|
|
454
486
|
let childCircleTag: number = this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).tag;
|
|
455
487
|
let circle = this.aMap?.addCircle(circleOptions);
|
|
456
488
|
//Put the overlay ring in the cache and hot-update the properties to modify
|
|
@@ -462,6 +494,7 @@ export struct AMapView {
|
|
|
462
494
|
circle.setStrokeColor(rgbaToHex(circleProp.strokeColor ? circleProp.strokeColor :
|
|
463
495
|
"rgba(0, 0, 255, 0.5)"));
|
|
464
496
|
circle.setStrokeWidth(circleProp.strokeWidth ? circleProp.strokeWidth : 5);
|
|
497
|
+
circle.setZIndex(circleProp.zIndex ? circleProp.zIndex : 2);
|
|
465
498
|
}
|
|
466
499
|
break;
|
|
467
500
|
case A_MAP_POLYGON_TYPE:
|
|
@@ -470,7 +503,7 @@ export struct AMapView {
|
|
|
470
503
|
let childPolygonTag: number = this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).tag;
|
|
471
504
|
GlobalCache.polygonCacheMap.set(childPolygonTag, polygon);
|
|
472
505
|
let mapPolygonProp =
|
|
473
|
-
this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).
|
|
506
|
+
this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).rawProps as AMapPolygonProps;
|
|
474
507
|
if (polygon) {
|
|
475
508
|
let polygonOptionsList = new ArrayList<LatLng>()
|
|
476
509
|
for (let index = 0; index < mapPolygonProp.points.length; index++) {
|
|
@@ -489,7 +522,7 @@ export struct AMapView {
|
|
|
489
522
|
case A_MAP_POLYLINE_TYPE:
|
|
490
523
|
flagLine = false;
|
|
491
524
|
let mapPolylineProp =
|
|
492
|
-
this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).
|
|
525
|
+
this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).rawProps as AMapPolylineProps;
|
|
493
526
|
let childPolyLineTag: number = this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i]).tag;
|
|
494
527
|
let GlobalCachePolyLines : Array<Polyline> = GlobalCache.mapPolyLine.get(this.tag) ?? [];
|
|
495
528
|
let polyLinesTagAndDescriptorTagArray: Array<HashMap<number, string>> = GlobalCache.polyLinesTagAndDescriptorTag.get(this.tag) ?? [];
|
|
@@ -503,7 +536,8 @@ export struct AMapView {
|
|
|
503
536
|
GlobalCachePolyLines[polylineIndex].setZIndex(mapPolylineProp.zIndex ? mapPolylineProp.zIndex : 1);
|
|
504
537
|
GlobalCachePolyLines[polylineIndex].setDottedLine(mapPolylineProp.dotted ? mapPolylineProp.dotted : false);
|
|
505
538
|
GlobalCachePolyLines[polylineIndex].setGeodesic(mapPolylineProp.geodesic ? mapPolylineProp.geodesic : false);
|
|
506
|
-
GlobalCachePolyLines[polylineIndex].setWidth(mapPolylineProp.width ?
|
|
539
|
+
GlobalCachePolyLines[polylineIndex].setWidth(mapPolylineProp.width ?
|
|
540
|
+
this.getUIContext().vp2px(mapPolylineProp.width) : this.getUIContext().vp2px(5));
|
|
507
541
|
if (mapPolylineProp.color) {
|
|
508
542
|
GlobalCachePolyLines[polylineIndex].setColor(rgbaToHex(mapPolylineProp.color ? mapPolylineProp.color :
|
|
509
543
|
"rgba(0, 255, 0, 0.5)"));
|
|
@@ -548,7 +582,8 @@ export struct AMapView {
|
|
|
548
582
|
.setZIndex(mapPolylineProp.zIndex ? mapPolylineProp.zIndex : 1)
|
|
549
583
|
.setDottedLine(mapPolylineProp.dotted ? mapPolylineProp.dotted : false)
|
|
550
584
|
.setGeodesic(mapPolylineProp.geodesic ? mapPolylineProp.geodesic : false)
|
|
551
|
-
.setWidth(mapPolylineProp.width ?
|
|
585
|
+
.setWidth(mapPolylineProp.width ?
|
|
586
|
+
this.getUIContext().vp2px(mapPolylineProp.width) : this.getUIContext().vp2px(5))
|
|
552
587
|
.setGradient(mapPolylineProp.gradient ? mapPolylineProp.gradient : false));
|
|
553
588
|
if(polyline){
|
|
554
589
|
polyline.setPoints(polylineOptionsList);
|
|
@@ -568,7 +603,7 @@ export struct AMapView {
|
|
|
568
603
|
case A_MAP_MARKER_TYPE:
|
|
569
604
|
let markerDescriptor: Descriptor = this.ctx.descriptorRegistry.getDescriptor(descriptor.childrenTags[i])
|
|
570
605
|
let markerChild: number[] = markerDescriptor.childrenTags;
|
|
571
|
-
let mapMarkerProps = markerDescriptor.
|
|
606
|
+
let mapMarkerProps = markerDescriptor.rawProps as AMapMarkerProps;
|
|
572
607
|
this.markers = (GlobalCache.mapMarker.get(this.tag) ?? []);
|
|
573
608
|
let markerTagAndDescriptorTagArray = GlobalCache.markerTagAndDescriptorTag.get(this.tag) ?? [];
|
|
574
609
|
|
|
@@ -595,10 +630,7 @@ export struct AMapView {
|
|
|
595
630
|
} else {
|
|
596
631
|
if (mapMarkerProps.icon) {
|
|
597
632
|
try {
|
|
598
|
-
|
|
599
|
-
let bitmapDes: BitmapDescriptor | undefined =
|
|
600
|
-
await BitmapDescriptorFactory.fromRawfilePath(globalContext, resoure);
|
|
601
|
-
this.markers[markerIndex].setIcon(bitmapDes);
|
|
633
|
+
await DownloadIcon.updataMakerIcon(this.getUIContext(), this.markers[markerIndex], mapMarkerProps.icon);
|
|
602
634
|
} catch (error) {
|
|
603
635
|
let bitmapDesNull: BitmapDescriptor | undefined =
|
|
604
636
|
await BitmapDescriptorFactory.fromRawfilePath(globalContext, "common/marker_default.png");
|
|
@@ -634,10 +666,7 @@ export struct AMapView {
|
|
|
634
666
|
} else {
|
|
635
667
|
if (mapMarkerProps.icon) {
|
|
636
668
|
try {
|
|
637
|
-
|
|
638
|
-
let bitmapDes: BitmapDescriptor | undefined =
|
|
639
|
-
await BitmapDescriptorFactory.fromRawfilePath(globalContext, resoure);
|
|
640
|
-
markerOptions.setIcon(bitmapDes);
|
|
669
|
+
await DownloadIcon.updataMakerIcon(this.getUIContext(), markerOptions, mapMarkerProps.icon);
|
|
641
670
|
} catch (error) {
|
|
642
671
|
let bitmapDesNull: BitmapDescriptor | undefined =
|
|
643
672
|
await BitmapDescriptorFactory.fromRawfilePath(globalContext, "common/marker_default.png");
|
|
@@ -672,15 +701,63 @@ export struct AMapView {
|
|
|
672
701
|
flagLine = false;
|
|
673
702
|
}
|
|
674
703
|
}
|
|
704
|
+
private startLocationUpdates() {
|
|
705
|
+
if (this.myLocationEnabled) {
|
|
706
|
+
let options: AMapLocationOption = {
|
|
707
|
+
priority: geoLocationManager.LocationRequestPriority.FIRST_FIX,
|
|
708
|
+
scenario: geoLocationManager.LocationRequestScenario.UNSET,
|
|
709
|
+
timeInterval: 2000,
|
|
710
|
+
distanceInterval: 0,
|
|
711
|
+
maxAccuracy: 20,
|
|
712
|
+
allowsBackgroundLocationUpdates: false,
|
|
713
|
+
locatingWithReGeocode: true,
|
|
714
|
+
reGeocodeLanguage: AMapLocationReGeocodeLanguage.Chinese,
|
|
715
|
+
isOffset: true
|
|
716
|
+
};
|
|
717
|
+
let locationListener: IAMapLocationListener = {
|
|
718
|
+
onLocationChanged: (location) => {
|
|
719
|
+
this.mapListener?.onLocationChanged(location)
|
|
720
|
+
},
|
|
721
|
+
onLocationError: (error) => {
|
|
722
|
+
console.error('失败: ' + JSON.stringify(error));
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
this.locationManager = new AMapLocationManagerImpl(globalContext);
|
|
726
|
+
this.locationManager?.setLocationListener(AMapLocationType.Updating, locationListener);
|
|
727
|
+
this.locationManager?.setLocationOption(AMapLocationType.Updating, options);
|
|
728
|
+
this.locationManager?.startUpdatingLocation();
|
|
729
|
+
|
|
730
|
+
}
|
|
731
|
+
}
|
|
675
732
|
|
|
733
|
+
private stopLocationUpdates() {
|
|
734
|
+
this.locationManager?.stopUpdatingLocation();
|
|
735
|
+
}
|
|
676
736
|
@Builder
|
|
677
737
|
customMarkerBuilder(markerTag: number) {
|
|
678
738
|
ContentSlot(this.ctx.getContentForTag(markerTag))
|
|
679
739
|
}
|
|
680
740
|
|
|
741
|
+
activate(listener: OnLocationChangedListener): void {
|
|
742
|
+
this.mapListener = listener;
|
|
743
|
+
this.locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
|
|
744
|
+
this.aMap?.setMyLocationStyle(this.locationStyle);
|
|
745
|
+
if (this.myLocationEnabled) {
|
|
746
|
+
this.startLocationUpdates();
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
deactivate() {
|
|
751
|
+
if (this.intervalId > 0) {
|
|
752
|
+
clearInterval(this.intervalId);
|
|
753
|
+
this.intervalId = 0;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
|
|
681
757
|
build() {
|
|
682
758
|
RNViewBase({ ctx: this.ctx, tag: this.tag }) {
|
|
683
759
|
MapViewComponent({ mapViewName: new String(this.tag).valueOf() }).width('100%').height('100%')
|
|
760
|
+
|
|
684
761
|
}
|
|
685
762
|
}
|
|
686
763
|
}
|
package/harmony/rn_amap3d.har
CHANGED
|
Binary file
|
package/lib/src/map-view.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import AMapView, { Location, MapViewProps, voidEvent } from './map-viewNativeCom
|
|
|
3
3
|
import React, { Component } from 'react';
|
|
4
4
|
import type * as ReactNative from "react-native";
|
|
5
5
|
import {NativeMethods} from "react-native";
|
|
6
|
-
import { LatLng, CameraPosition, LatLngBounds, onCameraEvent, MapPoi,
|
|
6
|
+
import { LatLng, CameraPosition, LatLngBounds, onCameraEvent, MapPoi, moveCameraCommands } from './map-viewNativeComponent'
|
|
7
7
|
|
|
8
8
|
export default class MapView extends Component<MapViewProps> {
|
|
9
9
|
constructor(props: MapViewProps) {
|
|
@@ -18,7 +18,7 @@ export default class MapView extends Component<MapViewProps> {
|
|
|
18
18
|
moveCamera(cameraPosition: CameraPosition, duration = 0) {
|
|
19
19
|
console.info("AMapViewEventType map3d demo moveCamera")
|
|
20
20
|
if (this.ref) {
|
|
21
|
-
|
|
21
|
+
moveCameraCommands.moveCamera(
|
|
22
22
|
this.ref,
|
|
23
23
|
cameraPosition,
|
|
24
24
|
duration
|
|
@@ -215,18 +215,13 @@ export interface MapViewProps extends ViewProps {
|
|
|
215
215
|
|
|
216
216
|
export default codegenNativeComponent<MapViewProps>("AMapView") as HostComponent<MapViewProps>;
|
|
217
217
|
type MapViewControlType = HostComponent<MapViewProps>;
|
|
218
|
-
|
|
219
218
|
export interface NativeCommands {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
bearing: Float,
|
|
226
|
-
tilt: Float,
|
|
227
|
-
duration: Float
|
|
228
|
-
) => void
|
|
219
|
+
moveCamera: (
|
|
220
|
+
viewRef: React.ElementRef<MapViewControlType>,
|
|
221
|
+
cameraPosition: Partial<CameraPosition>,
|
|
222
|
+
duration:number
|
|
223
|
+
) => void
|
|
229
224
|
}
|
|
230
|
-
export const
|
|
225
|
+
export const moveCameraCommands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
231
226
|
supportedCommands: ["moveCamera"],
|
|
232
227
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-ohos/react-native-amap3d",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.6-rc.1",
|
|
4
4
|
"description": "react-native 高德地图组件,支持 harmonyOS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -16,17 +16,23 @@
|
|
|
16
16
|
"react-native-amap3d.podspec",
|
|
17
17
|
"harmony"
|
|
18
18
|
],
|
|
19
|
-
"homepage": "https://
|
|
19
|
+
"homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-amap3d",
|
|
20
20
|
"repository": {
|
|
21
21
|
"type": "git",
|
|
22
|
-
"url": "https://
|
|
22
|
+
"url": "https://gitcode.com/openharmony-sig/rntpc_react-native-amap3d"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"start": "react-native start",
|
|
26
26
|
"reload": "adb reverse tcp:8081 tcp:8081 && adb shell input text rr"
|
|
27
27
|
},
|
|
28
28
|
"harmony": {
|
|
29
|
-
"alias": "react-native-amap3d"
|
|
29
|
+
"alias": "react-native-amap3d",
|
|
30
|
+
"autolinking": {
|
|
31
|
+
"etsPackageClassName": "MapViewPackage",
|
|
32
|
+
"cppPackageClassName": "MapViewPackage",
|
|
33
|
+
"cmakeLibraryTargetName": "rnoh_amap3d",
|
|
34
|
+
"ohPackageName": "@react-native-ohos/react-native-amap3d"
|
|
35
|
+
}
|
|
30
36
|
},
|
|
31
37
|
"dependencies": {
|
|
32
38
|
"supercluster": "^7.1.4",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|