Действительно, offset
свойство в соответствии с angular-google-maps репозиторий не предоставляется через компонент AgmSnazzyInfoWindow
. Один из способов обойти это ограничение - ввести пользовательский компонент, который расширяет AgmSnazzyInfoWindow
компонент и поддерживает указание свойства offset
, например:
import {
Component,
AfterViewInit,
Input
} from "@angular/core";
import { AgmSnazzyInfoWindow } from "@agm/snazzy-info-window";
@Component({
// tslint:disable-next-line:component-selector
selector: 'my-info-window',
template:
"<div #outerWrapper><div #viewContainer></div></div><ng-content></ng-content>"
})
export class MyInfoWindowComponent extends AgmSnazzyInfoWindow
implements AfterViewInit {
/**
* A custom padding size around the content of the info window.
*/
@Input() offset: {top: string, left: string};
ngAfterViewInit() {
super.ngAfterViewInit();
this._snazzyInfoWindowInitialized.then(() => {
this._nativeSnazzyInfoWindow._opts.offset = this.offset;
});
}
}
Теперь смещение можно указать так:
<agm-map [latitude]="center.lat" [longitude]="center.lng">
<agm-marker [latitude]="center.lat" [longitude]="center.lng">
<my-info-window
[offset]="{
top: '-60px',
left: '0px'
}"
>
<ng-template>
Phoenix
</ng-template>
</my-info-window>
</agm-marker>
</agm-map>
Вот демоверсия