Kargi-Sitesi/node_modules/@angular/google-maps/esm2022/map-transit-layer/map-transit-layer.mjs

69 lines
No EOL
8.9 KiB
JavaScript
Executable file

/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1265
/// <reference types="google.maps" preserve="true" />
import { Directive, EventEmitter, NgZone, Output, inject } from '@angular/core';
import { GoogleMap } from '../google-map/google-map';
import * as i0 from "@angular/core";
/**
* Angular component that renders a Google Maps Transit Layer via the Google Maps JavaScript API.
*
* See developers.google.com/maps/documentation/javascript/reference/map#TransitLayer
*/
export class MapTransitLayer {
constructor() {
this._map = inject(GoogleMap);
this._zone = inject(NgZone);
/** Event emitted when the transit layer is initialized. */
this.transitLayerInitialized = new EventEmitter();
}
ngOnInit() {
if (this._map._isBrowser) {
if (google.maps.TransitLayer && this._map.googleMap) {
this._initialize(this._map.googleMap, google.maps.TransitLayer);
}
else {
this._zone.runOutsideAngular(() => {
Promise.all([this._map._resolveMap(), google.maps.importLibrary('maps')]).then(([map, lib]) => {
this._initialize(map, lib.TransitLayer);
});
});
}
}
}
_initialize(map, layerConstructor) {
this._zone.runOutsideAngular(() => {
this.transitLayer = new layerConstructor();
this.transitLayerInitialized.emit(this.transitLayer);
this._assertLayerInitialized();
this.transitLayer.setMap(map);
});
}
ngOnDestroy() {
this.transitLayer?.setMap(null);
}
_assertLayerInitialized() {
if (!this.transitLayer) {
throw Error('Cannot interact with a Google Map Transit Layer before it has been initialized. ' +
'Please wait for the Transit Layer to load before trying to interact with it.');
}
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0-next.2", ngImport: i0, type: MapTransitLayer, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.0-next.2", type: MapTransitLayer, isStandalone: true, selector: "map-transit-layer", outputs: { transitLayerInitialized: "transitLayerInitialized" }, exportAs: ["mapTransitLayer"], ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0-next.2", ngImport: i0, type: MapTransitLayer, decorators: [{
type: Directive,
args: [{
selector: 'map-transit-layer',
exportAs: 'mapTransitLayer',
standalone: true,
}]
}], propDecorators: { transitLayerInitialized: [{
type: Output
}] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFwLXRyYW5zaXQtbGF5ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvZ29vZ2xlLW1hcHMvbWFwLXRyYW5zaXQtbGF5ZXIvbWFwLXRyYW5zaXQtbGF5ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgseUVBQXlFO0FBQ3pFLHFEQUFxRDtBQUVyRCxPQUFPLEVBQUMsU0FBUyxFQUFFLFlBQVksRUFBRSxNQUFNLEVBQXFCLE1BQU0sRUFBRSxNQUFNLEVBQUMsTUFBTSxlQUFlLENBQUM7QUFFakcsT0FBTyxFQUFDLFNBQVMsRUFBQyxNQUFNLDBCQUEwQixDQUFDOztBQUVuRDs7OztHQUlHO0FBTUgsTUFBTSxPQUFPLGVBQWU7SUFMNUI7UUFNVSxTQUFJLEdBQUcsTUFBTSxDQUFDLFNBQVMsQ0FBQyxDQUFDO1FBQ3pCLFVBQUssR0FBRyxNQUFNLENBQUMsTUFBTSxDQUFDLENBQUM7UUFTL0IsMkRBQTJEO1FBQ3hDLDRCQUF1QixHQUN4QyxJQUFJLFlBQVksRUFBNEIsQ0FBQztLQXVDaEQ7SUFyQ0MsUUFBUTtRQUNOLElBQUksSUFBSSxDQUFDLElBQUksQ0FBQyxVQUFVLEVBQUUsQ0FBQztZQUN6QixJQUFJLE1BQU0sQ0FBQyxJQUFJLENB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