* Opens the MapInfoWindow using the provided anchor. If the anchor is not set, * then the position property of the options input is used instead.
(anchor?: MapAnchorPoint, shouldFocus?: boolean, content?: string | Element | Text)
| 209 | * then the position property of the options input is used instead. |
| 210 | */ |
| 211 | open(anchor?: MapAnchorPoint, shouldFocus?: boolean, content?: string | Element | Text): void { |
| 212 | this._assertInitialized(); |
| 213 | |
| 214 | if ((typeof ngDevMode === 'undefined' || ngDevMode) && anchor && !anchor.getAnchor) { |
| 215 | throw new Error( |
| 216 | 'Specified anchor does not implement the `getAnchor` method. ' + |
| 217 | 'It cannot be used to open an info window.', |
| 218 | ); |
| 219 | } |
| 220 | |
| 221 | const anchorObject = anchor ? anchor.getAnchor() : undefined; |
| 222 | |
| 223 | // Prevent the info window from initializing when trying to reopen on the same anchor. |
| 224 | // Note that when the window is opened for the first time, the anchor will always be |
| 225 | // undefined. If that's the case, we have to allow it to open in order to handle the |
| 226 | // case where the window doesn't have an anchor, but is placed at a particular position. |
| 227 | if (this.infoWindow.get('anchor') !== anchorObject || !anchorObject) { |
| 228 | // If no explicit content is provided, it is taken from the DOM node. |
| 229 | // If it is, we need to hide it so it doesn't take up space on the page. |
| 230 | this._elementRef.nativeElement.style.display = content ? 'none' : ''; |
| 231 | if (content) { |
| 232 | this.infoWindow.setContent(content); |
| 233 | } |
| 234 | this.infoWindow.open({ |
| 235 | map: this._googleMap.googleMap, |
| 236 | anchor: anchorObject, |
| 237 | shouldFocus, |
| 238 | }); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | private _combineOptions(): Observable<google.maps.InfoWindowOptions> { |
| 243 | return combineLatest([this._options, this._position]).pipe( |
no test coverage detected