UNPKG

@grupo-san-cristobal/agm-snazzy-info-window

Version:

Angular Google Maps (AGM) package for Snazzy Info Window support

1 lines 15.9 kB
{"version":3,"file":"grupo-san-cristobal-agm-snazzy-info-window.mjs","sources":["../../../packages/snazzy-info-window/src/lib/directives/snazzy-info-window.ts","../../../packages/snazzy-info-window/src/lib/snazzy-info-window.module.ts","../../../packages/snazzy-info-window/src/public-api.ts","../../../packages/snazzy-info-window/src/grupo-san-cristobal-agm-snazzy-info-window.ts"],"sourcesContent":["import { AgmMarker, GoogleMapsAPIWrapper, MapsAPILoader, MarkerManager } from '@grupo-san-cristobal/agm-core';\nimport { AfterViewInit, Component, ContentChild, ElementRef, EventEmitter, Host, Input, OnChanges, OnDestroy, Optional, Output, SimpleChanges, SkipSelf, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core';\n\ndeclare var require: any;\n\n@Component({\n // tslint:disable-next-line:component-selector\n selector: 'agm-snazzy-info-window',\n template: '<div #outerWrapper><div #viewContainer></div></div><ng-content></ng-content>',\n standalone: false\n})\nexport class AgmSnazzyInfoWindow implements AfterViewInit, OnDestroy, OnChanges {\n /**\n * The latitude and longitude where the info window is anchored.\n * The offset will default to 0px when using this option. Only required/used if you are not using a agm-marker.\n */\n @Input() latitude: number;\n\n /**\n * The longitude where the info window is anchored.\n * The offset will default to 0px when using this option. Only required/used if you are not using a agm-marker.\n */\n @Input() longitude: number;\n\n /**\n * Changes the open status of the snazzy info window.\n */\n @Input() isOpen = false;\n\n /**\n * Emits when the open status changes.\n */\n @Output() isOpenChange: EventEmitter<boolean> = new EventEmitter<boolean>();\n\n /**\n * Choose where you want the info window to be displayed, relative to the marker.\n */\n @Input() placement: 'top' | 'bottom' | 'left' | 'right' = 'top';\n\n /**\n * The max width in pixels of the info window.\n */\n @Input() maxWidth: number | string = 200;\n\n /**\n * The max height in pixels of the info window.\n */\n @Input() maxHeight: number | string = 200;\n\n /**\n * The color to use for the background of the info window.\n */\n @Input() backgroundColor: string;\n\n /**\n * A custom padding size around the content of the info window.\n */\n @Input() padding: string;\n\n /**\n * A custom border around the info window. Set to false to completely remove the border.\n * The units used for border should be the same as pointer.\n */\n @Input() border: {width: string; color: string} | boolean;\n\n /**\n * A custom CSS border radius property to specify the rounded corners of the info window.\n */\n @Input() borderRadius: string;\n\n /**\n * The font color to use for the content inside the body of the info window.\n */\n @Input() fontColor: string;\n\n /**\n * The font size to use for the content inside the body of the info window.\n */\n @Input() fontSize: string;\n\n /**\n * The height of the pointer from the info window to the marker.\n * Set to false to completely remove the pointer.\n * The units used for pointer should be the same as border.\n */\n @Input() pointer: string | boolean;\n\n /**\n * The CSS properties for the shadow of the info window.\n * Set to false to completely remove the shadow.\n */\n @Input() shadow: boolean | {h?: string, v?: string, blur: string, spread: string, opacity: number, color: string};\n\n /**\n * Determines if the info window will open when the marker is clicked.\n * An internal listener is added to the Google Maps click event which calls the open() method.\n */\n @Input() openOnMarkerClick = true;\n\n /**\n * Determines if the info window will close when the map is clicked. An internal listener is added to\n * the Google Maps click event which calls the close() method.\n * This will not activate on the Google Maps drag event when the user is panning the map.\n */\n @Input() closeOnMapClick = true;\n\n /**\n * An optional CSS class to assign to the wrapper container of the info window.\n * Can be used for applying custom CSS to the info window.\n */\n @Input() wrapperClass: string;\n\n /**\n * Determines if the info window will close when any other Snazzy Info Window is opened.\n */\n @Input() closeWhenOthersOpen = false;\n\n /**\n * Determines if the info window will show a close button.\n */\n @Input() showCloseButton = true;\n\n /**\n * Determines if the info window will be panned into view when opened.\n */\n @Input() panOnOpen = true;\n\n /**\n * Emits before the info window opens.\n */\n @Output() beforeOpen: EventEmitter<void> = new EventEmitter<void>();\n\n /**\n * Emits before the info window closes.\n */\n @Output() afterClose: EventEmitter<void> = new EventEmitter<void>();\n\n /**\n * @internal\n */\n @ViewChild('outerWrapper', {read: ElementRef, static: false}) _outerWrapper: ElementRef;\n\n /**\n * @internal\n */\n @ViewChild('viewContainer', {read: ViewContainerRef, static: false}) _viewContainerRef: ViewContainerRef;\n\n /**\n * @internal\n */\n @ContentChild(TemplateRef, {static: false}) _templateRef: TemplateRef<any>;\n\n protected _nativeSnazzyInfoWindow: any;\n protected _snazzyInfoWindowInitialized: Promise<any> | null = null;\n\n constructor(\n @Optional() @Host() @SkipSelf() private _marker: AgmMarker,\n private _wrapper: GoogleMapsAPIWrapper,\n private _manager: MarkerManager,\n private _loader: MapsAPILoader,\n ) {}\n\n /**\n * @internal\n */\n ngOnChanges(changes: SimpleChanges) {\n if (this._nativeSnazzyInfoWindow == null) {\n return;\n }\n if ('isOpen' in changes && this.isOpen) {\n this._openInfoWindow();\n } else if ('isOpen' in changes && !this.isOpen) {\n this._closeInfoWindow();\n }\n if (('latitude' in changes || 'longitude' in changes) && this._marker == null) {\n this._updatePosition();\n }\n }\n\n /**\n * @internal\n */\n ngAfterViewInit() {\n const m = this._manager != null ? this._manager.getNativeMarker(this._marker) : null;\n this._snazzyInfoWindowInitialized = this._loader.load()\n .then(() => require('snazzy-info-window'))\n .then((module: any) => Promise.all([module, m, this._wrapper.getNativeMap()]))\n .then((elems) => {\n const options: any = {\n map: elems[2],\n content: '',\n placement: this.placement,\n maxWidth: this.maxWidth,\n maxHeight: this.maxHeight,\n backgroundColor: this.backgroundColor,\n padding: this.padding,\n border: this.border,\n borderRadius: this.borderRadius,\n fontColor: this.fontColor,\n pointer: this.pointer,\n shadow: this.shadow,\n closeOnMapClick: this.closeOnMapClick,\n openOnMarkerClick: this.openOnMarkerClick,\n closeWhenOthersOpen: this.closeWhenOthersOpen,\n showCloseButton: this.showCloseButton,\n panOnOpen: this.panOnOpen,\n wrapperClass: this.wrapperClass,\n callbacks: {\n beforeOpen: () => {\n this._createViewContent();\n this.beforeOpen.emit();\n },\n afterOpen: () => {\n this.isOpenChange.emit(this.openStatus());\n },\n afterClose: () => {\n this.afterClose.emit();\n this.isOpenChange.emit(this.openStatus());\n },\n },\n };\n if (elems[1] != null) {\n options.marker = elems[1];\n } else {\n options.position = {\n lat: this.latitude,\n lng: this.longitude,\n };\n }\n this._nativeSnazzyInfoWindow = new elems[0](options);\n });\n this._snazzyInfoWindowInitialized.then(() => {\n if (this.isOpen) {\n this._openInfoWindow();\n }\n });\n }\n\n protected _openInfoWindow() {\n this._snazzyInfoWindowInitialized.then(() => {\n this._createViewContent();\n this._nativeSnazzyInfoWindow.open();\n });\n }\n\n protected _closeInfoWindow() {\n this._snazzyInfoWindowInitialized.then(() => {\n this._nativeSnazzyInfoWindow.close();\n });\n }\n\n protected _createViewContent() {\n if (this._viewContainerRef.length === 1) {\n return;\n }\n const evr = this._viewContainerRef.createEmbeddedView(this._templateRef);\n this._nativeSnazzyInfoWindow.setContent(this._outerWrapper.nativeElement);\n // we have to run this in a separate cycle.\n setTimeout(() => {\n evr.detectChanges();\n });\n }\n\n protected _updatePosition() {\n this._nativeSnazzyInfoWindow.setPosition({\n lat: this.latitude,\n lng: this.longitude,\n });\n }\n\n /**\n * Returns true when the Snazzy Info Window is initialized and open.\n */\n openStatus(): boolean {\n return this._nativeSnazzyInfoWindow && this._nativeSnazzyInfoWindow.isOpen();\n }\n\n /**\n * @internal\n */\n ngOnDestroy() {\n if (this._nativeSnazzyInfoWindow) {\n this._nativeSnazzyInfoWindow.destroy();\n }\n }\n}\n","import { NgModule } from '@angular/core';\nimport { AgmSnazzyInfoWindow } from './directives/snazzy-info-window';\n\n@NgModule({\n declarations: [AgmSnazzyInfoWindow],\n exports: [AgmSnazzyInfoWindow],\n})\nexport class AgmSnazzyInfoWindowModule {}\n","/*\n * Public API Surface of snazzy-info-window\n */\n\nexport * from './lib/directives/snazzy-info-window';\nexport * from './lib/snazzy-info-window.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAWa,mBAAmB,CAAA;AAgJ9B,IAAA,WAAA,CAC0C,OAAkB,EAClD,QAA8B,EAC9B,QAAuB,EACvB,OAAsB,EAAA;QAHU,IAAO,CAAA,OAAA,GAAP,OAAO;QACvC,IAAQ,CAAA,QAAA,GAA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