Skip to content

Commit 129f4ef

Browse files
committed
feat(iOS): Add indoor events for iOS
1 parent a086010 commit 129f4ef

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

src/map-view.ios.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,62 @@ export * from "./map-view-common";
1515

1616
declare function UIEdgeInsetsMake(...params: any[]): any;
1717

18+
class IndoorDisplayDelegateImpl extends NSObject implements GMSIndoorDisplayDelegate {
19+
20+
public static ObjCProtocols = [GMSIndoorDisplayDelegate];
21+
22+
private _owner: WeakRef<MapView>;
23+
24+
public static initWithOwner(owner: WeakRef<MapView>): IndoorDisplayDelegateImpl {
25+
let handler = <IndoorDisplayDelegateImpl>IndoorDisplayDelegateImpl.new();
26+
handler._owner = owner;
27+
return handler;
28+
}
29+
30+
public didChangeActiveBuilding(indoorBuilding: GMSIndoorBuilding): void {
31+
let owner = this._owner.get();
32+
if (owner) {
33+
let data = null;
34+
if (indoorBuilding) {
35+
const levels = [];
36+
let count = 0;
37+
38+
while (count < indoorBuilding.levels.count) {
39+
levels.push(
40+
{
41+
name: indoorBuilding.levels[count].name,
42+
shortName: indoorBuilding.levels[count].shortName,
43+
}
44+
);
45+
count += 1;
46+
}
47+
48+
data = {
49+
defaultLevelIndex: indoorBuilding.defaultLevelIndex,
50+
levels: levels,
51+
isUnderground: indoorBuilding.underground,
52+
};
53+
}
54+
owner.notifyBuildingFocusedEvent(data);
55+
}
56+
}
57+
58+
public didChangeActiveLevel(activateLevel: GMSIndoorLevel): void {
59+
let owner = this._owner.get();
60+
if (owner) {
61+
let data = null;
62+
if (activateLevel) {
63+
data = {
64+
name: activateLevel.name,
65+
shortName: activateLevel.shortName,
66+
};
67+
}
68+
owner.notifyIndoorLevelActivatedEvent(data);
69+
}
70+
}
71+
}
72+
73+
1874
class MapViewDelegateImpl extends NSObject implements GMSMapViewDelegate {
1975

2076
public static ObjCProtocols = [GMSMapViewDelegate];

0 commit comments

Comments
 (0)