/*! * devextreme-angular-test * Version: 17.2.8 * Build date: Mon Feb 05 2018 * * Copyright (c) 2012 - 2018 Developer Express Inc. ALL RIGHTS RESERVED * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file in the root of the project for details. * * https://github.com/DevExpress/devextreme-angular */ import { Component, NgModule, ElementRef, NgZone, Input, Output, OnDestroy, Injector, EventEmitter, OnChanges, DoCheck, SimpleChanges, ContentChildren, QueryList } from '@angular/core'; import DxMap from 'devextreme/ui/map'; import { DxComponent } from '../core/component'; import { DxTemplateHost } from '../core/template-host'; import { DxTemplateModule } from '../core/template'; import { EventsRegistrator } from '../core/events-strategy'; import { NestedOptionHost } from '../core/nested-option'; import { WatcherHelper } from '../core/watcher-helper'; import { IterableDifferHelper } from '../core/iterable-differ-helper'; import { DxiCenterModule } from './nested/center-dxi'; import { DxoKeyModule } from './nested/key'; import { DxiMarkerModule } from './nested/marker-dxi'; import { DxiLocationModule } from './nested/location-dxi'; import { DxoTooltipModule } from './nested/tooltip'; import { DxiRouteModule } from './nested/route-dxi'; import { DxiCenterComponent } from './nested/center-dxi'; import { DxiMarkerComponent } from './nested/marker-dxi'; import { DxiRouteComponent } from './nested/route-dxi'; /** * The Map is an interactive widget that displays a geographic map with markers and routes. */ @Component({ selector: 'dx-map', template: '', providers: [ DxTemplateHost, WatcherHelper, NestedOptionHost, IterableDifferHelper ] }) export class DxMapComponent extends DxComponent implements OnDestroy, OnChanges, DoCheck { instance: DxMap; /** * Specifies the shortcut key that sets focus on the widget. */ @Input() get accessKey(): string { return this._getOption('accessKey'); } set accessKey(value: string) { this._setOption('accessKey', value); } /** * Specifies whether or not the widget changes its state when interacting with a user. */ @Input() get activeStateEnabled(): boolean { return this._getOption('activeStateEnabled'); } set activeStateEnabled(value: boolean) { this._setOption('activeStateEnabled', value); } /** * Specifies whether or not the widget automatically adjusts center and zoom option values when adding a new marker or route, or when creating a widget if it initially contains markers or routes. */ @Input() get autoAdjust(): boolean { return this._getOption('autoAdjust'); } set autoAdjust(value: boolean) { this._setOption('autoAdjust', value); } /** * An object, a string, or an array specifying the location displayed at the center of the widget. */ @Input() get center(): string| Array { return this._getOption('center'); } set center(value: string| Array) { this._setOption('center', value); } /** * Specifies whether or not map widget controls are available. */ @Input() get controls(): boolean { return this._getOption('controls'); } set controls(value: boolean) { this._setOption('controls', value); } /** * Specifies whether the widget responds to user interaction. */ @Input() get disabled(): boolean { return this._getOption('disabled'); } set disabled(value: boolean) { this._setOption('disabled', value); } /** * Specifies the attributes to be attached to the widget's root element. */ @Input() get elementAttr(): any { return this._getOption('elementAttr'); } set elementAttr(value: any) { this._setOption('elementAttr', value); } /** * Specifies whether the widget can be focused using keyboard navigation. */ @Input() get focusStateEnabled(): boolean { return this._getOption('focusStateEnabled'); } set focusStateEnabled(value: boolean) { this._setOption('focusStateEnabled', value); } /** * Specifies the widget's height. */ @Input() get height(): number| Function| string { return this._getOption('height'); } set height(value: number| Function| string) { this._setOption('height', value); } /** * Specifies text for a hint that appears when a user pauses on the widget. */ @Input() get hint(): string { return this._getOption('hint'); } set hint(value: string) { this._setOption('hint', value); } /** * Specifies whether the widget changes its state when a user pauses on it. */ @Input() get hoverStateEnabled(): boolean { return this._getOption('hoverStateEnabled'); } set hoverStateEnabled(value: boolean) { this._setOption('hoverStateEnabled', value); } /** * A key used to authenticate the application within the required map provider. */ @Input() get key(): string| { bing?: string, google?: string, googleStatic?: string } { return this._getOption('key'); } set key(value: string| { bing?: string, google?: string, googleStatic?: string }) { this._setOption('key', value); } /** * A URL pointing to the custom icon to be used for map markers. */ @Input() get markerIconSrc(): string { return this._getOption('markerIconSrc'); } set markerIconSrc(value: string) { this._setOption('markerIconSrc', value); } /** * An array of markers displayed on a map. */ @Input() get markers(): Array, onClick?: Function, tooltip?: string| { isShown?: boolean, text?: string } }> { return this._getOption('markers'); } set markers(value: Array, onClick?: Function, tooltip?: string| { isShown?: boolean, text?: string } }>) { this._setOption('markers', value); } /** * The name of the current map data provider. */ @Input() get provider(): string { return this._getOption('provider'); } set provider(value: string) { this._setOption('provider', value); } /** * An array of routes shown on the map. */ @Input() get routes(): Array, mode?: string, opacity?: number, weight?: number }> { return this._getOption('routes'); } set routes(value: Array, mode?: string, opacity?: number, weight?: number }>) { this._setOption('routes', value); } /** * Switches the widget to a right-to-left representation. */ @Input() get rtlEnabled(): boolean { return this._getOption('rtlEnabled'); } set rtlEnabled(value: boolean) { this._setOption('rtlEnabled', value); } /** * Specifies the number of the element when the Tab key is used for navigating. */ @Input() get tabIndex(): number { return this._getOption('tabIndex'); } set tabIndex(value: number) { this._setOption('tabIndex', value); } /** * The type of a map to display. */ @Input() get type(): string { return this._getOption('type'); } set type(value: string) { this._setOption('type', value); } /** * Specifies whether the widget is visible. */ @Input() get visible(): boolean { return this._getOption('visible'); } set visible(value: boolean) { this._setOption('visible', value); } /** * Specifies the widget's width. */ @Input() get width(): number| Function| string { return this._getOption('width'); } set width(value: number| Function| string) { this._setOption('width', value); } /** * The zoom level of the map. */ @Input() get zoom(): number { return this._getOption('zoom'); } set zoom(value: number) { this._setOption('zoom', value); } /** * A handler for the click event. */ @Output() onClick: EventEmitter; /** * A handler for the disposing event. Executed when the widget is removed from the DOM using the remove(), empty(), or html() jQuery methods only. */ @Output() onDisposing: EventEmitter; /** * A handler for the initialized event. Executed only once, after the widget is initialized. */ @Output() onInitialized: EventEmitter; /** * A handler for the markerAdded event. */ @Output() onMarkerAdded: EventEmitter; /** * A handler for the markerRemoved event. */ @Output() onMarkerRemoved: EventEmitter; /** * A handler for the optionChanged event. Executed after an option of the widget is changed. */ @Output() onOptionChanged: EventEmitter; /** * A handler for the ready event. */ @Output() onReady: EventEmitter; /** * A handler for the routeAdded event. */ @Output() onRouteAdded: EventEmitter; /** * A handler for the routeRemoved event. */ @Output() onRouteRemoved: EventEmitter; /** * A handler for the accessKeyChange event. */ @Output() accessKeyChange: EventEmitter; /** * A handler for the activeStateEnabledChange event. */ @Output() activeStateEnabledChange: EventEmitter; /** * A handler for the autoAdjustChange event. */ @Output() autoAdjustChange: EventEmitter; /** * A handler for the centerChange event. */ @Output() centerChange: EventEmitter>; /** * A handler for the controlsChange event. */ @Output() controlsChange: EventEmitter; /** * A handler for the disabledChange event. */ @Output() disabledChange: EventEmitter; /** * A handler for the elementAttrChange event. */ @Output() elementAttrChange: EventEmitter; /** * A handler for the focusStateEnabledChange event. */ @Output() focusStateEnabledChange: EventEmitter; /** * A handler for the heightChange event. */ @Output() heightChange: EventEmitter; /** * A handler for the hintChange event. */ @Output() hintChange: EventEmitter; /** * A handler for the hoverStateEnabledChange event. */ @Output() hoverStateEnabledChange: EventEmitter; /** * A handler for the keyChange event. */ @Output() keyChange: EventEmitter; /** * A handler for the markerIconSrcChange event. */ @Output() markerIconSrcChange: EventEmitter; /** * A handler for the markersChange event. */ @Output() markersChange: EventEmitter, onClick?: Function, tooltip?: string| { isShown?: boolean, text?: string } }>>; /** * A handler for the providerChange event. */ @Output() providerChange: EventEmitter; /** * A handler for the routesChange event. */ @Output() routesChange: EventEmitter, mode?: string, opacity?: number, weight?: number }>>; /** * A handler for the rtlEnabledChange event. */ @Output() rtlEnabledChange: EventEmitter; /** * A handler for the tabIndexChange event. */ @Output() tabIndexChange: EventEmitter; /** * A handler for the typeChange event. */ @Output() typeChange: EventEmitter; /** * A handler for the visibleChange event. */ @Output() visibleChange: EventEmitter; /** * A handler for the widthChange event. */ @Output() widthChange: EventEmitter; /** * A handler for the zoomChange event. */ @Output() zoomChange: EventEmitter; @ContentChildren(DxiCenterComponent) get centerChildren(): QueryList { return this._getOption('center'); } set centerChildren(value) { this.setChildren('center', value); } @ContentChildren(DxiMarkerComponent) get markersChildren(): QueryList { return this._getOption('markers'); } set markersChildren(value) { this.setChildren('markers', value); } @ContentChildren(DxiRouteComponent) get routesChildren(): QueryList { return this._getOption('routes'); } set routesChildren(value) { this.setChildren('routes', value); } constructor(elementRef: ElementRef, ngZone: NgZone, templateHost: DxTemplateHost, injector: Injector, private _watcherHelper: WatcherHelper, private _idh: IterableDifferHelper, optionHost: NestedOptionHost) { super(elementRef, ngZone, templateHost, _watcherHelper); injector.get(EventsRegistrator); this._createEventEmitters([ { subscribe: 'click', emit: 'onClick' }, { subscribe: 'disposing', emit: 'onDisposing' }, { subscribe: 'initialized', emit: 'onInitialized' }, { subscribe: 'markerAdded', emit: 'onMarkerAdded' }, { subscribe: 'markerRemoved', emit: 'onMarkerRemoved' }, { subscribe: 'optionChanged', emit: 'onOptionChanged' }, { subscribe: 'ready', emit: 'onReady' }, { subscribe: 'routeAdded', emit: 'onRouteAdded' }, { subscribe: 'routeRemoved', emit: 'onRouteRemoved' }, { emit: 'accessKeyChange' }, { emit: 'activeStateEnabledChange' }, { emit: 'autoAdjustChange' }, { emit: 'centerChange' }, { emit: 'controlsChange' }, { emit: 'disabledChange' }, { emit: 'elementAttrChange' }, { emit: 'focusStateEnabledChange' }, { emit: 'heightChange' }, { emit: 'hintChange' }, { emit: 'hoverStateEnabledChange' }, { emit: 'keyChange' }, { emit: 'markerIconSrcChange' }, { emit: 'markersChange' }, { emit: 'providerChange' }, { emit: 'routesChange' }, { emit: 'rtlEnabledChange' }, { emit: 'tabIndexChange' }, { emit: 'typeChange' }, { emit: 'visibleChange' }, { emit: 'widthChange' }, { emit: 'zoomChange' } ]); this._idh.setHost(this); optionHost.setHost(this); } protected _createInstance(element, options) { return new DxMap(element, options); } ngOnDestroy() { this._destroyWidget(); } ngOnChanges(changes: SimpleChanges) { super.ngOnChanges(changes); this.setupChanges('center', changes); this.setupChanges('markers', changes); this.setupChanges('routes', changes); } setupChanges(prop: string, changes: SimpleChanges) { if (!(prop in this._optionsToUpdate)) { this._idh.setup(prop, changes); } } ngDoCheck() { this._idh.doCheck('center'); this._idh.doCheck('markers'); this._idh.doCheck('routes'); this._watcherHelper.checkWatchers(); super.ngDoCheck(); } _setOption(name: string, value: any) { let isSetup = this._idh.setupSingle(name, value); let isChanged = this._idh.getChanges(name, value) !== null; if (isSetup || isChanged) { super._setOption(name, value); } } } @NgModule({ imports: [ DxiCenterModule, DxoKeyModule, DxiMarkerModule, DxiLocationModule, DxoTooltipModule, DxiRouteModule, DxTemplateModule ], declarations: [ DxMapComponent ], exports: [ DxMapComponent, DxiCenterModule, DxoKeyModule, DxiMarkerModule, DxiLocationModule, DxoTooltipModule, DxiRouteModule, DxTemplateModule ], providers: [EventsRegistrator] }) export class DxMapModule { }