@@ -35,6 +35,7 @@ export struct AIRMapMarker {
35
35
@BuilderParam buildCustomComponent: (componentBuilderContext: ComponentBuilderContext) => void
36
36
@State descriptor: AIRMapMarkerDescriptor = {} as AIRMapMarkerDescriptor
37
37
protected cleanUpCallbacks: (() => void)[] = []
38
+ private marker?: map.Marker;
38
39
39
40
aboutToAppear() {
40
41
LWLog('AIRMapMarker.aboutToAppear 初始化 AIRMapMarker...')
@@ -46,7 +47,7 @@ export struct AIRMapMarker {
46
47
this.marker?.setPosition({latitude: this.descriptor.rawProps.coordinate.latitude, longitude: this.descriptor.rawProps.coordinate.longitude})
47
48
this.marker?.setRotation(this.descriptor.rawProps.rotation);
48
49
this.marker?.setZIndex(this.descriptor.rawProps.zIndex);
49
- this.marker?.setAlpha(this.descriptor.rawProps.opacity?this.descriptor.rawProps.opacity: 1.0);
50
+ this.marker?.setAlpha(this.descriptor.rawProps.opacity ?? 1.0);
50
51
this.marker?.setMarkerAnchor(MapsManager.getInstance().getPointX(this.descriptor.rawProps.anchor, 0.5), MapsManager.getInstance().getPointX(this.descriptor.rawProps.anchor, 1));
51
52
this.marker?.setClickable(this.descriptor.rawProps.tappable===undefined?true:this.descriptor.rawProps.tappable);
52
53
this.marker?.setDraggable(this.descriptor.rawProps.draggable===undefined?true:this.descriptor.rawProps.draggable);
@@ -62,13 +63,9 @@ export struct AIRMapMarker {
62
63
(command, args: [ESObject, ESObject, ESObject]) => {
63
64
LWLog('AIRMapMarker.aboutToAppear----------command=' + command, JSON.stringify(args))
64
65
if (command === 'showCallout') {
65
- if (this.marker) {
66
- this.marker.setInfoWindowVisible(true);
67
- }
66
+ this.marker?.setInfoWindowVisible(true);
68
67
} else if (command === 'hideCallout') {
69
- if (this.marker) {
70
- this.marker.setInfoWindowVisible(false);
71
- }
68
+ this.marker?.setInfoWindowVisible(false);
72
69
} else if (command === 'redrawCallout') {
73
70
//todo 华为地图不支持 当infoWindow为自定义view的时候,调用此方法更新infoWindow里的内容
74
71
} else if (command === 'animateMarkerToCoordinate') {
@@ -99,12 +96,6 @@ export struct AIRMapMarker {
99
96
});
100
97
}
101
98
102
- private marker?: map.Marker;
103
-
104
- public setMarker(marker: map.Marker){
105
- this.marker = marker;
106
- }
107
-
108
99
aboutToDisappear() {
109
100
this.cleanUpCallbacks.forEach(cb => cb());
110
101
this.marker?.remove();
0 commit comments