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

151 lines
No EOL
20 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 { Input, NgZone, Directive, Output, EventEmitter, } from '@angular/core';
import { GoogleMap } from '../google-map/google-map';
import * as i0 from "@angular/core";
import * as i1 from "../google-map/google-map";
/**
* Angular directive that renders a Google Maps heatmap via the Google Maps JavaScript API.
*
* See: https://developers.google.com/maps/documentation/javascript/reference/visualization
*/
export class MapHeatmapLayer {
/**
* Data shown on the heatmap.
* See: https://developers.google.com/maps/documentation/javascript/reference/visualization
*/
set data(data) {
this._data = data;
}
/**
* Options used to configure the heatmap. See:
* developers.google.com/maps/documentation/javascript/reference/visualization#HeatmapLayerOptions
*/
set options(options) {
this._options = options;
}
constructor(_googleMap, _ngZone) {
this._googleMap = _googleMap;
this._ngZone = _ngZone;
/** Event emitted when the heatmap is initialized. */
this.heatmapInitialized = new EventEmitter();
}
ngOnInit() {
if (this._googleMap._isBrowser) {
if (!window.google?.maps?.visualization &&
!window.google?.maps.importLibrary &&
(typeof ngDevMode === 'undefined' || ngDevMode)) {
throw Error('Namespace `google.maps.visualization` not found, cannot construct heatmap. ' +
'Please install the Google Maps JavaScript API with the "visualization" library: ' +
'https://developers.google.com/maps/documentation/javascript/visualization');
}
if (google.maps.visualization?.HeatmapLayer && this._googleMap.googleMap) {
this._initialize(this._googleMap.googleMap, google.maps.visualization.HeatmapLayer);
}
else {
this._ngZone.runOutsideAngular(() => {
Promise.all([
this._googleMap._resolveMap(),
google.maps.importLibrary('visualization'),
]).then(([map, lib]) => {
this._initialize(map, lib.HeatmapLayer);
});
});
}
}
}
_initialize(map, heatmapConstructor) {
// 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.heatmap = new heatmapConstructor(this._combineOptions());
this._assertInitialized();
this.heatmap.setMap(map);
this.heatmapInitialized.emit(this.heatmap);
});
}
ngOnChanges(changes) {
const { _data, heatmap } = this;
if (heatmap) {
if (changes['options']) {
heatmap.setOptions(this._combineOptions());
}
if (changes['data'] && _data !== undefined) {
heatmap.setData(this._normalizeData(_data));
}
}
}
ngOnDestroy() {
this.heatmap?.setMap(null);
}
/**
* Gets the data that is currently shown on the heatmap.
* See: developers.google.com/maps/documentation/javascript/reference/visualization#HeatmapLayer
*/
getData() {
this._assertInitialized();
return this.heatmap.getData();
}
/** Creates a combined options object using the passed-in options and the individual inputs. */
_combineOptions() {
const options = this._options || {};
return {
...options,
data: this._normalizeData(this._data || options.data || []),
map: this._googleMap.googleMap,
};
}
/**
* Most Google Maps APIs support both `LatLng` objects and `LatLngLiteral`. The latter is more
* convenient to write out, because the Google Maps API doesn't have to have been loaded in order
* to construct them. The `HeatmapLayer` appears to be an exception that only allows a `LatLng`
* object, or it throws a runtime error. Since it's more convenient and we expect that Angular
* users will load the API asynchronously, we allow them to pass in a `LatLngLiteral` and we
* convert it to a `LatLng` object before passing it off to Google Maps.
*/
_normalizeData(data) {
const result = [];
data.forEach(item => {
result.push(isLatLngLiteral(item) ? new google.maps.LatLng(item.lat, item.lng) : item);
});
return result;
}
/** Asserts that the heatmap object has been initialized. */
_assertInitialized() {
if (typeof ngDevMode === 'undefined' || ngDevMode) {
if (!this.heatmap) {
throw Error('Cannot interact with a Google Map HeatmapLayer before it has been ' +
'initialized. Please wait for the heatmap 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: MapHeatmapLayer, 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: MapHeatmapLayer, isStandalone: true, selector: "map-heatmap-layer", inputs: { data: "data", options: "options" }, outputs: { heatmapInitialized: "heatmapInitialized" }, exportAs: ["mapHeatmapLayer"], usesOnChanges: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0-next.2", ngImport: i0, type: MapHeatmapLayer, decorators: [{
type: Directive,
args: [{
selector: 'map-heatmap-layer',
exportAs: 'mapHeatmapLayer',
standalone: true,
}]
}], ctorParameters: () => [{ type: i1.GoogleMap }, { type: i0.NgZone }], propDecorators: { data: [{
type: Input
}], options: [{
type: Input
}], heatmapInitialized: [{
type: Output
}] } });
/** Asserts that an object is a `LatLngLiteral`. */
function isLatLngLiteral(value) {
return value && typeof value.lat === 'number' && typeof value.lng === 'number';
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFwLWhlYXRtYXAtbGF5ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvZ29vZ2xlLW1hcHMvbWFwLWhlYXRtYXAtbGF5ZXIvbWFwLWhlYXRtYXAtbGF5ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgseUVBQXlFO0FBQ3pFLHFEQUFxRDtBQUVyRCxPQUFPLEVBQ0wsS0FBSyxFQUdMLE1BQU0sRUFDTixTQUFTLEVBR1QsTUFBTSxFQUNOLFlBQVksR0FDYixNQUFNLGVBQWUsQ0FBQztBQUV2QixPQUFPLEVBQUMsU0FBUyxFQUFDLE1BQU0sMEJBQTBCLENBQUM7OztBQVNuRDs7OztHQUlHO0FBTUgsTUFBTSxPQUFPLGVBQWU7SUFDMUI7OztPQUdHO0lBQ0gsSUFDSSxJQUFJLENBQUMsSUFBaUI7UUFDeEIsSUFBSSxDQUFDLEtBQUssR0FBR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