Skip to content

Commit 14d6b48

Browse files
authored
feat(google-maps): marker visible accessors (#313)
1 parent 7219ebd commit 14d6b48

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

packages/google-maps/index.android.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,14 @@ export class Marker extends OverLayBase implements IMarker {
10701070
this.native.setRotation(value);
10711071
}
10721072

1073+
get visible(): boolean {
1074+
return this.native.isVisible();
1075+
}
1076+
1077+
set visible(value) {
1078+
this.native.setVisible(value);
1079+
}
1080+
10731081
get flat(): boolean {
10741082
return this.native.isFlat();
10751083
}

packages/google-maps/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ export interface IMarker {
296296
icon: any /* Image, ImageSource, UIImage & Bitmap */;
297297
color: Color | string;
298298
rotation: number;
299+
visible: boolean;
299300
flat: boolean;
300301
zIndex: number;
301302
userData: { [key: string]: any };
@@ -315,6 +316,7 @@ export class Marker implements IMarker, Partial<NativeObject> {
315316
icon: any; /* Image, ImageSource, UIImage & Bitmap */
316317
color: Color | string;
317318
rotation: number;
319+
visible: boolean;
318320
flat: boolean;
319321
zIndex: number;
320322
userData: { [key: string]: any };

packages/google-maps/index.ios.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,7 @@ abstract class OverLayBase {
984984
export class Marker extends OverLayBase implements IMarker {
985985
#native: GMSMarker;
986986
#color = new Color('red');
987+
#visible = true;
987988
static fromNative(nativeMarker: GMSMarker) {
988989
if (nativeMarker instanceof GMSMarker) {
989990
const marker = new Marker();
@@ -1079,6 +1080,15 @@ export class Marker extends OverLayBase implements IMarker {
10791080
this.native.rotation = value;
10801081
}
10811082

1083+
get visible(): boolean {
1084+
return this.#visible;
1085+
}
1086+
1087+
set visible(value: boolean) {
1088+
this.#visible = value;
1089+
this.native.opacity = this.visible ? 1 : 0;
1090+
}
1091+
10821092
get flat(): boolean {
10831093
return this.native.flat;
10841094
}

packages/google-maps/utils/index.android.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ export function intoNativeMarkerOptions(options: MarkerOptions) {
8080
opts.rotation(options.rotation);
8181
}
8282

83+
if (typeof options?.visible === 'boolean') {
84+
opts.visible(options.visible);
85+
}
86+
8387
if (typeof options?.flat === 'boolean') {
8488
opts.flat(options.flat);
8589
}

packages/google-maps/utils/index.ios.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ export function intoNativeMarkerOptions(options: MarkerOptions) {
6464
opts.rotation = options.rotation;
6565
}
6666

67+
if (typeof options?.visible === 'boolean') {
68+
opts.opacity = options.visible ? 1 : 0;
69+
}
70+
6771
if (typeof options?.flat === 'boolean') {
6872
opts.flat = options.flat;
6973
}

0 commit comments

Comments
 (0)