UNPKG

angular2-google-maps

Version:

Angular 2 components for Google Maps

113 lines 4.68 kB
import { Directive, EventEmitter } from '@angular/core'; import { KmlLayerManager } from './../services/managers/kml-layer-manager'; var layerId = 0; export var SebmGoogleMapKmlLayer = (function () { function SebmGoogleMapKmlLayer(_manager) { this._manager = _manager; this._addedToManager = false; this._id = (layerId++).toString(); this._subscriptions = []; /** * If true, the layer receives mouse events. Default value is true. */ this.clickable = true; /** * By default, the input map is centered and zoomed to the bounding box of the contents of the * layer. * If this option is set to true, the viewport is left unchanged, unless the map's center and zoom * were never set. */ this.preserveViewport = false; /** * Whether to render the screen overlays. Default true. */ this.screenOverlays = true; /** * Suppress the rendering of info windows when layer features are clicked. */ this.suppressInfoWindows = false; /** * The URL of the KML document to display. */ this.url = null; /** * The z-index of the layer. */ this.zIndex = null; /** * This event is fired when a feature in the layer is clicked. */ this.layerClick = new EventEmitter(); /** * This event is fired when the KML layers default viewport has changed. */ this.defaultViewportChange = new EventEmitter(); /** * This event is fired when the KML layer has finished loading. * At this point it is safe to read the status property to determine if the layer loaded * successfully. */ this.statusChange = new EventEmitter(); } SebmGoogleMapKmlLayer.prototype.ngOnInit = function () { if (this._addedToManager) { return; } this._manager.addKmlLayer(this); this._addedToManager = true; this._addEventListeners(); }; SebmGoogleMapKmlLayer.prototype.ngOnChanges = function (changes) { if (!this._addedToManager) { return; } this._updatePolygonOptions(changes); }; SebmGoogleMapKmlLayer.prototype._updatePolygonOptions = function (changes) { var options = Object.keys(changes) .filter(function (k) { return SebmGoogleMapKmlLayer._kmlLayerOptions.indexOf(k) !== -1; }) .reduce(function (obj, k) { obj[k] = changes[k].currentValue; return obj; }, {}); if (Object.keys(options).length > 0) { this._manager.setOptions(this, options); } }; SebmGoogleMapKmlLayer.prototype._addEventListeners = function () { var _this = this; var listeners = [ { name: 'click', handler: function (ev) { return _this.layerClick.emit(ev); } }, { name: 'defaultviewport_changed', handler: function () { return _this.defaultViewportChange.emit(); } }, { name: 'status_changed', handler: function () { return _this.statusChange.emit(); } }, ]; listeners.forEach(function (obj) { var os = _this._manager.createEventObservable(obj.name, _this).subscribe(obj.handler); _this._subscriptions.push(os); }); }; /** @internal */ SebmGoogleMapKmlLayer.prototype.id = function () { return this._id; }; /** @internal */ SebmGoogleMapKmlLayer.prototype.toString = function () { return "SebmGoogleMapKmlLayer-" + this._id.toString(); }; /** @internal */ SebmGoogleMapKmlLayer.prototype.ngOnDestroy = function () { this._manager.deleteKmlLayer(this); // unsubscribe all registered observable subscriptions this._subscriptions.forEach(function (s) { return s.unsubscribe(); }); }; SebmGoogleMapKmlLayer._kmlLayerOptions = ['clickable', 'preserveViewport', 'screenOverlays', 'suppressInfoWindows', 'url', 'zIndex']; SebmGoogleMapKmlLayer.decorators = [ { type: Directive, args: [{ selector: 'sebm-google-map-kml-layer', inputs: ['clickable', 'preserveViewport', 'screenOverlays', 'suppressInfoWindows', 'url', 'zIndex'], outputs: ['layerClick', 'defaultViewportChange', 'statusChange'] },] }, ]; /** @nocollapse */ SebmGoogleMapKmlLayer.ctorParameters = function () { return [ { type: KmlLayerManager, }, ]; }; return SebmGoogleMapKmlLayer; }()); //# sourceMappingURL=google-map-kml-layer.js.map