{"version":3,"file":"ajf-core-map.mjs","sources":["../../../projects/core/map/src/map-container-directive.ts","../../../projects/core/map/src/map.ts","../../../projects/core/map/src/map.html","../../../projects/core/map/src/map-module.ts","../../../projects/core/map/src/public_api.ts","../../../projects/core/map/src/ajf-core-map.ts"],"sourcesContent":["/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nimport {Directive, ElementRef} from '@angular/core';\n\n// eslint-disable-next-line\n@Directive({selector: '[mapContainer]'})\nexport class AjfMapContainerDirective {\n  get htmlElement(): HTMLElement {\n    return this._el.nativeElement;\n  }\n\n  constructor(private _el: ElementRef) {}\n}\n","/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nimport {\n  AfterViewInit,\n  ChangeDetectionStrategy,\n  Component,\n  Input,\n  OnDestroy,\n  ViewChild,\n  ViewEncapsulation,\n} from '@angular/core';\nimport * as leaflet from 'leaflet';\n// tslint:disable-next-line:no-duplicate-imports\nimport {Map} from 'leaflet';\nimport {Subscription} from 'rxjs';\n\nimport {AjfMapContainerDirective} from './map-container-directive';\n\nconst {map, tileLayer} = ((leaflet as any).default || leaflet) as typeof leaflet;\n\n@Component({\n  selector: 'ajf-map',\n  templateUrl: 'map.html',\n  styleUrls: ['map.scss'],\n  changeDetection: ChangeDetectionStrategy.OnPush,\n  encapsulation: ViewEncapsulation.None,\n})\nexport class AjfMapComponent implements AfterViewInit, OnDestroy {\n  @ViewChild(AjfMapContainerDirective, {static: true})\n  mapContainer!: AjfMapContainerDirective;\n\n  private _coordinate: number[] = [];\n  @Input()\n  set coordinate(coordinate: number[]) {\n    this._coordinate = coordinate.slice(0);\n    this._setMapView();\n  }\n\n  private _tileLayer: string | undefined;\n  @Input()\n  set tileLayer(tl: string | undefined) {\n    this._tileLayer = tl;\n    this._addTileLayerToMap();\n  }\n\n  private _attribution: string = '';\n  @Input()\n  set attribution(attribution: string) {\n    this._attribution = attribution;\n    this._addTileLayerToMap();\n  }\n\n  private _disabled: boolean = false;\n  @Input()\n  set disabled(disabled: boolean) {\n    this._disabled = disabled;\n    this._disableMap();\n  }\n\n  private _map: Map | undefined;\n  get map(): Map | undefined {\n    return this._map;\n  }\n\n  private _columnWidthChanged: Subscription = Subscription.EMPTY;\n\n  ngAfterViewInit(): void {\n    if (this.mapContainer) {\n      this._initMap();\n      this._setMapView();\n      this._addTileLayerToMap();\n      this._disableMap();\n    }\n  }\n\n  redraw() {\n    if (this.mapContainer && this._map) {\n      this._map.invalidateSize();\n    }\n  }\n\n  ngOnDestroy() {\n    this._columnWidthChanged.unsubscribe();\n  }\n\n  private _initMap(): void {\n    const options = {zoomControl: false, attributionControl: false};\n\n    this._map = map(this.mapContainer.htmlElement, options);\n  }\n\n  private _setMapView(): void {\n    if (this._map == null) {\n      return;\n    }\n\n    let x, y, z;\n    if (this._coordinate != null && this._coordinate.length === 3) {\n      x = this._coordinate[0];\n      y = this._coordinate[1];\n      z = this._coordinate[2];\n    } else {\n      x = 0;\n      y = 0;\n      z = 14;\n    }\n    this._map.setView([x, y], z);\n  }\n\n  private _addTileLayerToMap(): void {\n    if (this._map == null || this._tileLayer == null) {\n      return;\n    }\n    const map = this._map;\n    map.eachLayer(l => map.removeLayer(l));\n    tileLayer(this._tileLayer, {attribution: this._attribution}).addTo(map);\n  }\n\n  private _disableMap(): void {\n    if (this._map == null) {\n      return;\n    }\n\n    if (this._disabled) {\n      this._map.dragging.disable();\n      this._map.touchZoom.disable();\n      this._map.doubleClickZoom.disable();\n      this._map.scrollWheelZoom.disable();\n      this._map.boxZoom.disable();\n      this._map.keyboard.disable();\n      if (this._map.tap) {\n        this._map.tap.disable();\n      }\n    }\n  }\n}\n","<div mapContainer></div>\n","/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nimport {NgModule} from '@angular/core';\n\nimport {AjfMapComponent} from './map';\nimport {AjfMapContainerDirective} from './map-container-directive';\n\n@NgModule({\n  declarations: [AjfMapComponent, AjfMapContainerDirective],\n  exports: [AjfMapComponent],\n})\nexport class AjfMapModule {}\n","/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nexport * from './map-module';\nexport * from './map';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["i1.AjfMapContainerDirective"],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;AAoBG;AAIH;MAEa,wBAAwB,CAAA;AACnC,IAAA,IAAI,WAAW,GAAA;AACb,QAAA,OAAO,IAAI,CAAC,GAAG,CAAC,aAAa;;AAG/B,IAAA,WAAA,CAAoB,GAAe,EAAA;QAAf,IAAG,CAAA,GAAA,GAAH,GAAG;;+GALZ,wBAAwB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,UAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;mGAAxB,wBAAwB,EAAA,QAAA,EAAA,gBAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAAxB,wBAAwB,EAAA,UAAA,EAAA,CAAA;kBADpC,SAAS;mBAAC,EAAC,QAAQ,EAAE,gBAAgB,EAAC;;;ACzBvC;;;;;;;;;;;;;;;;;;;;AAoBG;AAkBH,MAAM,EAAC,GAAG,EAAE,SAAS,EAAC,IAAK,OAAe,CAAC,OAAO,IAAI,OAAO,CAAmB;MASnE,eAAe,CAAA;AAP5B,IAAA,WAAA,GAAA;QAWU,IAAW,CAAA,WAAA,GAAa,EAAE;QAc1B,IAAY,CAAA,YAAA,GAAW,EAAE;QAOzB,IAAS,CAAA,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