Kargi-Sitesi/node_modules/@angular/google-maps/esm2022/map-directions-renderer/map-directions-renderer.mjs

149 lines
No EOL
18 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, Input, NgZone, Output, inject, } from '@angular/core';
import { Observable } from 'rxjs';
import { GoogleMap } from '../google-map/google-map';
import { MapEventManager } from '../map-event-manager';
import * as i0 from "@angular/core";
import * as i1 from "../google-map/google-map";
/**
* Angular component that renders a Google Maps Directions Renderer via the Google Maps
* JavaScript API.
*
* See developers.google.com/maps/documentation/javascript/reference/directions#DirectionsRenderer
*/
export class MapDirectionsRenderer {
/**
* See developers.google.com/maps/documentation/javascript/reference/directions
* #DirectionsRendererOptions.directions
*/
set directions(directions) {
this._directions = directions;
}
/**
* See developers.google.com/maps/documentation/javascript/reference/directions
* #DirectionsRendererOptions
*/
set options(options) {
this._options = options;
}
constructor(_googleMap, _ngZone) {
this._googleMap = _googleMap;
this._ngZone = _ngZone;
this._eventManager = new MapEventManager(inject(NgZone));
/**
* See developers.google.com/maps/documentation/javascript/reference/directions
* #DirectionsRenderer.directions_changed
*/
this.directionsChanged = this._eventManager.getLazyEmitter('directions_changed');
/** Event emitted when the directions renderer is initialized. */
this.directionsRendererInitialized = new EventEmitter();
}
ngOnInit() {
if (this._googleMap._isBrowser) {
if (google.maps.DirectionsRenderer && this._googleMap.googleMap) {
this._initialize(this._googleMap.googleMap, google.maps.DirectionsRenderer);
}
else {
this._ngZone.runOutsideAngular(() => {
Promise.all([this._googleMap._resolveMap(), google.maps.importLibrary('routes')]).then(([map, lib]) => {
this._initialize(map, lib.DirectionsRenderer);
});
});
}
}
}
_initialize(map, rendererConstructor) {
// Create the object outside the zone so its events don't trigger change detection.
// We'll bring it back in inside the `MapEventManager` only for the events that the
// user has subscribed to.
this._ngZone.runOutsideAngular(() => {
this.directionsRenderer = new rendererConstructor(this._combineOptions());
this._assertInitialized();
this.directionsRenderer.setMap(map);
this._eventManager.setTarget(this.directionsRenderer);
this.directionsRendererInitialized.emit(this.directionsRenderer);
});
}
ngOnChanges(changes) {
if (this.directionsRenderer) {
if (changes['options']) {
this.directionsRenderer.setOptions(this._combineOptions());
}
if (changes['directions'] && this._directions !== undefined) {
this.directionsRenderer.setDirections(this._directions);
}
}
}
ngOnDestroy() {
this._eventManager.destroy();
this.directionsRenderer?.setMap(null);
}
/**
* See developers.google.com/maps/documentation/javascript/reference/directions
* #DirectionsRenderer.getDirections
*/
getDirections() {
this._assertInitialized();
return this.directionsRenderer.getDirections();
}
/**
* See developers.google.com/maps/documentation/javascript/reference/directions
* #DirectionsRenderer.getPanel
*/
getPanel() {
this._assertInitialized();
return this.directionsRenderer.getPanel();
}
/**
* See developers.google.com/maps/documentation/javascript/reference/directions
* #DirectionsRenderer.getRouteIndex
*/
getRouteIndex() {
this._assertInitialized();
return this.directionsRenderer.getRouteIndex();
}
_combineOptions() {
const options = this._options || {};
return {
...options,
directions: this._directions || options.directions,
map: this._googleMap.googleMap,
};
}
_assertInitialized() {
if (typeof ngDevMode === 'undefined' || ngDevMode) {
if (!this.directionsRenderer) {
throw Error('Cannot interact with a Google Map Directions Renderer before it has been ' +
'initialized. Please wait for the Directions Renderer 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: MapDirectionsRenderer, deps: [{ token: i1.GoogleMap }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive }); }
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.0-next.2", type: MapDirectionsRenderer, isStandalone: true, selector: "map-directions-renderer", inputs: { directions: "directions", options: "options" }, outputs: { directionsChanged: "directionsChanged", directionsRendererInitialized: "directionsRendererInitialized" }, exportAs: ["mapDirectionsRenderer"], usesOnChanges: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0-next.2", ngImport: i0, type: MapDirectionsRenderer, decorators: [{
type: Directive,
args: [{
selector: 'map-directions-renderer',
exportAs: 'mapDirectionsRenderer',
standalone: true,
}]
}], ctorParameters: () => [{ type: i1.GoogleMap }, { type: i0.NgZone }], propDecorators: { directions: [{
type: Input
}], options: [{
type: Input
}], directionsChanged: [{
type: Output
}], directionsRendererInitialized: [{
type: Output
}] } });
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFwLWRpcmVjdGlvbnMtcmVuZGVyZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvZ29vZ2xlLW1hcHMvbWFwLWRpcmVjdGlvbnMtcmVuZGVyZXIvbWFwLWRpcmVjdGlvbnMtcmVuZGVyZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgseUVBQXlFO0FBQ3pFLHFEQUFxRDtBQUVyRCxPQUFPLEVBQ0wsU0FBUyxFQUNULFlBQVksRUFDWixLQUFLLEVBQ0wsTUFBTSxFQUlOLE1BQU0sRUFFTixNQUFNLEdBQ1AsTUFBTSxlQUFlLENBQUM7QUFDdkIsT0FBTyxFQUFDLFVBQVUsRUFBQyxNQUFNLE1BQU0sQ0FBQztBQUNoQyxPQUFPLEVBQUMsU0FBUyxFQUFDLE1BQU0sMEJBQTBCLENBQUM7QUFDbkQsT0FBTyxFQUFDLGVBQWUsRUFBQyxNQUFNLHNCQUFzQixDQUFDOzs7QUFFckQ7Ozs7O0dBS0c7QUFNSCxNQUFNLE9BQU8scUJBQXFCO0lBR2hDOzs7T0FHRztJQUNILElBQ0ksVUFBVSxDQUFDLFVBQXdDO1FBQ3JELElBQUksQ0FBQyxXQUFXLEdBQUc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