Skip to content

Commit 56be6e0

Browse files
committed
fix(google-maps): info window
1 parent a640b54 commit 56be6e0

File tree

3 files changed

+42
-29
lines changed

3 files changed

+42
-29
lines changed

packages/google-maps/index.android.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Application, Color, Device, EventData, ImageSource, Utils, View } from '@nativescript/core';
1+
import { Application, Color, Device, EventData, GridLayout, ImageSource, Utils, View } from '@nativescript/core';
22
import { isNullOrUndefined } from '@nativescript/core/utils/types';
33
import {
44
ActiveBuildingEvent,
@@ -310,21 +310,28 @@ export class MapView extends MapViewBase {
310310
if (info) {
311311
owner.notify(info);
312312
if (info.view instanceof View) {
313-
if (!info.view.parent && !info.view?.nativeView) {
314-
owner._addView(info.view);
315-
}
316-
if (info.view.nativeView && !(<any>marker)._view) {
317-
(<any>marker)._view = new android.widget.RelativeLayout(owner._context);
318-
}
319-
const parent = info.view.nativeView?.getParent?.();
320-
if (info.view.nativeView && parent !== (<any>marker)._view) {
321-
if (parent && parent.removeView) {
322-
parent.removeView(info.view.nativeView);
313+
let container = (<any>marker)._view as never as GridLayout;
314+
if (!container) {
315+
container = new GridLayout();
316+
(<any>marker)._view = container;
317+
const activity = Utils.android.getCurrentActivity();
318+
container._setupAsRootView(activity);
319+
container._setupUI(activity);
320+
container.callLoaded();
321+
} else {
322+
if (info.view.parent !== container) {
323+
container.removeChildren();
323324
}
324-
const container: android.widget.RelativeLayout = (<any>marker)._view;
325-
container.addView(info.view.nativeView);
326325
}
327-
return (<any>marker)?._view ?? null;
326+
327+
if (!info.view.parent) {
328+
container.addChild(info.view);
329+
} else if (info.view.parent !== container) {
330+
(<GridLayout>info?.view?.parent)?.removeChild?.(info.view);
331+
container.addChild(info.view);
332+
}
333+
334+
return info.view.nativeView;
328335
} else if (info.view instanceof android.view.View) {
329336
return info.view;
330337
}

packages/google-maps/index.ios.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Color, EventData, ImageSource, Utils, View } from '@nativescript/core';
1+
import { Color, EventData, GridLayout, ImageSource, Utils, View } from '@nativescript/core';
22
import { isNullOrUndefined } from '@nativescript/core/utils/types';
33
import {
44
ActiveBuildingEvent,
@@ -478,21 +478,27 @@ class GMSMapViewDelegateImpl extends NSObject implements GMSMapViewDelegate {
478478
owner.notify(event);
479479

480480
if (event.view instanceof View) {
481-
if (!event.view.parent && !event.view?.nativeView) {
482-
owner._addView(event.view);
483-
}
484-
if (event.view.nativeView && !(<any>marker)._view) {
485-
(<any>marker)._view = UIView.new();
486-
}
487-
const parent = event.view.nativeView?.superview;
488-
if (event.view.nativeView && parent !== (<any>marker)._view) {
489-
if (parent) {
490-
event.view.nativeView.removeFromSuperview();
481+
let container = (<any>marker)._view as never as GridLayout;
482+
if (!container) {
483+
container = new GridLayout();
484+
(<any>marker)._view = container;
485+
container._setupAsRootView({});
486+
container._setupUI({});
487+
container.callLoaded();
488+
} else {
489+
if (event.view.parent !== container) {
490+
container.removeChildren();
491491
}
492-
const container: UIView = (<any>marker)._view;
493-
container.addSubview(event.view.nativeView);
494492
}
495-
return (<any>marker)?._view ?? null;
493+
494+
if (!event.view.parent) {
495+
container.addChild(event.view);
496+
} else if (event.view.parent !== container) {
497+
(<GridLayout>event?.view?.parent)?.removeChild?.(event.view);
498+
container.addChild(event.view);
499+
}
500+
501+
return event.view.nativeView;
496502
} else if (event.view instanceof UIView) {
497503
return event.view;
498504
}

packages/google-maps/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript/google-maps",
3-
"version": "1.7.2",
3+
"version": "1.7.4",
44
"description": "Google Maps SDK",
55
"main": "index",
66
"typings": "index.d.ts",

0 commit comments

Comments
 (0)