UNPKG

ng2-heremaps

Version:
136 lines 3.99 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ import { Directive, Input, Output, EventEmitter, forwardRef } from '@angular/core'; import { HereMapsManager } from '../services/maps-manager'; import { BaseMapComponent } from './base-map-component'; import { toLatLng } from '../utils/position'; /** * Renders buble on map. Please note that directive must be placed inside * map component, otherwise it will never be rendered. */ export class MapBubbleDirective extends BaseMapComponent { /** * @param {?} _mapsManager */ constructor(_mapsManager) { super(); this._mapsManager = _mapsManager; /** * This event is fired when the marker icon was clicked. */ this.click = new EventEmitter(); this._clickable = true; } /** * Bubble position * @param {?} point * @return {?} */ set position(point) { const /** @type {?} */ position = toLatLng(point); this._mapsManager .createBubble({ position }) .then((bubble) => { this.bindEvents(bubble); this.proxyResolver(bubble); }); this.proxy.then(bubble => { bubble.setPosition(toLatLng(point)); }); } /** * If true, the marker receives mouse and touch events. * Default value is true. * @param {?} mode * @return {?} */ set clickable(mode) { // this.proxy.then(marker => marker.setClickable(mode)); this._clickable = mode; } /** * Rollover text * @param {?} value * @return {?} */ set contentElement(value) { this.proxy.then(bubble => bubble.setContent(value)); } /** * @return {?} */ hasMapComponent() { return !!this.mapComponent; } /** * @param {?} component * @param {?} map * @param {?} ui * @return {?} */ setMapComponent(component, map, ui) { this.mapComponent = component; this.proxy.then((mapObject) => setTimeout(() => { if (mapObject instanceof H.ui.InfoBubble) { ui.addBubble(mapObject); } }, this.delay || 0)); } /** * @param {?} marker * @return {?} */ bindEvents(marker) { marker.addEventListener('tap', e => { if (this._clickable) { this.click.emit(e); } }); } } MapBubbleDirective.decorators = [ { type: Directive, args: [{ selector: 'map-bubble', providers: [ { provide: BaseMapComponent, useExisting: forwardRef(() => MapBubbleDirective) } ] },] } ]; /** @nocollapse */ MapBubbleDirective.ctorParameters = () => [ { type: HereMapsManager, }, ]; MapBubbleDirective.propDecorators = { "click": [{ type: Output },], "position": [{ type: Input },], "clickable": [{ type: Input },], "contentElement": [{ type: Input },], }; function MapBubbleDirective_tsickle_Closure_declarations() { /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */ MapBubbleDirective.decorators; /** * @nocollapse * @type {function(): !Array<(null|{type: ?, decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>)})>} */ MapBubbleDirective.ctorParameters; /** @type {!Object<string,!Array<{type: !Function, args: (undefined|!Array<?>)}>>} */ MapBubbleDirective.propDecorators; /** @type {?} */ MapBubbleDirective.prototype.mapComponent; /** * This event is fired when the marker icon was clicked. * @type {?} */ MapBubbleDirective.prototype.click; /** @type {?} */ MapBubbleDirective.prototype._clickable; /** @type {?} */ MapBubbleDirective.prototype._mapsManager; } //# sourceMappingURL=map-bubble.js.map