UNPKG

ng2-bingmaps

Version:
106 lines (104 loc) 4.17 kB
/** * ng2-bingmaps - Angular 2 components for Bing Maps * @version v0.2.0 * @link https://github.com/youjustgo/ng2-bingmaps * @license MIT */ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { Component, EventEmitter, ContentChildren, QueryList } from '@angular/core'; import { InfoWindowManager } from '../services/info-window-manager'; import { BingMapInfoWindowAction } from './bing-map-info-window-action'; let infoWindowId = 0; /** * BingMapInfoWindow renders a info window inside a {@link BingMapMarker} or standalone. * * ### Example * ```typescript * import {Component} from '@angular/core'; * import {NG2_BINGMAPS_DIRECTIVES} from 'ng2-bingmaps/core'; * * @Component({ * selector: 'my-map-cmp', * directives: [NG2_BINGMAPS_DIRECTIVES], * styles: [` * .bing-map-container { * height: 300px; * } * `], * template: ` * <bing-map [latitude]="lat" [longitude]="lng" [zoom]="zoom"> * <bing-map-marker [latitude]="lat" [longitude]="lng" [label]="'M'"> * <bing-map-info-window [title]="title" [description]="description" [height]="height" [width]="width"> * </bing-map-info-window> * </bing-map-marker> * </bing-map> * ` * }) * ``` */ export let BingMapInfoWindow = class BingMapInfoWindow { constructor(_infoWindowManager) { this._infoWindowManager = _infoWindowManager; /** * Emits an event when the info window is closed. */ this.infoWindowClose = new EventEmitter(); this._id = (infoWindowId++).toString(); } /** @internal */ ngOnChanges(changes) { // todo check if opened, ask the infowindowmanager // then implement below. // if ((changes['latitude'] || changes['longitude']) && typeof this.latitude === 'number' && // typeof this.longitude === 'number') { // this._infoWindowManager.setPosition(this); // } // this._setInfoWindowOptions(changes); } // private _setInfoWindowOptions(changes: {[key: string]: SimpleChange}) { // let options: {[propName: string]: any} = {}; // let optionKeys = Object.keys(changes).filter( // k => BingMapInfoWindow._infoWindowOptionsInputs.indexOf(k) !== -1); // optionKeys.forEach((k) => { options[k] = changes[k].currentValue; }); // this._infoWindowManager.setOptions(options); // } /** * Opens the info window. */ open() { return this._infoWindowManager.open(this); } /** * Closes the info window. */ close() { return this._infoWindowManager.close().then(() => { this.infoWindowClose.emit(void 0); }); } /** @internal */ id() { return this._id; } /** @internal */ toString() { return 'BingMapInfoWindow-' + this._id.toString(); } }; BingMapInfoWindow._infoWindowOptionsInputs = ['disableAutoPan', 'maxWidth', 'title', 'description']; __decorate([ ContentChildren(BingMapInfoWindowAction), __metadata('design:type', QueryList) ], BingMapInfoWindow.prototype, "infoWindowActions", void 0); BingMapInfoWindow = __decorate([ Component({ selector: 'bing-map-info-window', inputs: ['latitude', 'longitude', 'disableAutoPan', 'title', 'description', 'height', 'width'], template: '', outputs: ['infoWindowClose'] }), __metadata('design:paramtypes', [InfoWindowManager]) ], BingMapInfoWindow); //# sourceMappingURL=bing-map-info-window.js.map