Skip to content
This repository was archived by the owner on Jun 23, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/directives/google-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,20 @@ export class SebmGoogleMap implements OnChanges,
}
}

/**
* Triggers a resize event on the google map instance.
* Returns a promise that gets resolved after the event was triggered.
*/
triggerResize(): Promise<void> {
// Note: When we would trigger the resize event and show the map in the same turn (which is a
// common case for triggering a resize event), then the resize event would not
// work (to show the map), so we trigger the event in a timeout.
return new Promise<void>((resolve) => {
setTimeout(
() => { return this._mapsWrapper.triggerMapEvent('resize').then(() => resolve()); });
});
}

/**
* Sets the zoom level of the map. The default value is `8`.
*/
Expand Down
7 changes: 7 additions & 0 deletions src/services/google-maps-api-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,11 @@ export class GoogleMapsAPIWrapper {
}

getMap(): Promise<mapTypes.GoogleMap> { return this._map; }

/**
* Triggers the given event name on the map instance.
*/
triggerMapEvent(eventName: string): Promise<void> {
return this._map.then((m) => google.maps.event.trigger(m, eventName));
}
}