UNPKG

ng2-heremaps

Version:
233 lines 7.79 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ import * as tslib_1 from "tslib"; import { Directive, Input, forwardRef } from '@angular/core'; import { BaseMapComponent } from './base-map-component'; import { HereMapsManager } from '../services/maps-manager'; /** * Directive that will render plyline to map. Please note that directive must be placed inside * map component, otherwise it will never render polyline. */ var MapPolylineDirective = /** @class */ (function (_super) { tslib_1.__extends(MapPolylineDirective, _super); function MapPolylineDirective(mapsManager) { var _this = _super.call(this) || this; _this._lineWidth = 4; mapsManager .onApiLoad() .then(function () { var /** @type {?} */ strip = new H.geo.Strip(); _this.polyline = new H.map.Polyline(strip); _this.proxyResolver(_this.polyline); }); return _this; } Object.defineProperty(MapPolylineDirective.prototype, "fillColor", { /** * Fill color that should be used when polyline is rendered on map */ get: /** * Fill color that should be used when polyline is rendered on map * @return {?} */ function () { return this._fillColor; }, set: /** * @param {?} color * @return {?} */ function (color) { if (this._fillColor !== color) { this._fillColor = color; this.proxy.then(function (p) { var /** @type {?} */ style = Object.assign({}, p.getStyle()); style.fillColor = color; p.setStyle(style); }); } }, enumerable: true, configurable: true }); Object.defineProperty(MapPolylineDirective.prototype, "strokeColor", { /** * Stroke color that should be used when polyline is rendered on map */ get: /** * Stroke color that should be used when polyline is rendered on map * @return {?} */ function () { return this._strokeColor; }, set: /** * @param {?} color * @return {?} */ function (color) { if (this._strokeColor !== color) { this._strokeColor = color; this.proxy.then(function (p) { var /** @type {?} */ style = Object.assign({}, p.getStyle()); style.strokeColor = color; p.setStyle(style); }); } }, enumerable: true, configurable: true }); Object.defineProperty(MapPolylineDirective.prototype, "lineWidth", { /** * Gives plyline with */ get: /** * Gives plyline with * @return {?} */ function () { return this._lineWidth; }, set: /** * @param {?} lineWidth * @return {?} */ function (lineWidth) { if (this._lineWidth !== lineWidth) { this._lineWidth = lineWidth; this.proxy.then(function (p) { var /** @type {?} */ style = Object.assign({}, p.getStyle()); style.lineWidth = lineWidth; p.setStyle(style); }); } }, enumerable: true, configurable: true }); Object.defineProperty(MapPolylineDirective.prototype, "options", { set: /** * @param {?} opts * @return {?} */ function (opts) { var _this = this; this.proxy.then(function (polyline) { var /** @type {?} */ style = { strokeColor: opts.strokeColor || _this.strokeColor, fillColor: opts.fillColor || _this.fillColor, lineWidth: opts.lineWidth || _this.lineWidth }, /** @type {?} */ strip = new H.geo.Strip(); (opts.path || []) .forEach(function (point) { strip.pushPoint({ lat: point.lat, lng: point.lng }); }); polyline.setStrip(strip); polyline.setStyle(style); }); }, enumerable: true, configurable: true }); /** * Checks if map is set to directive * @return {?} */ MapPolylineDirective.prototype.hasMapComponent = /** * Checks if map is set to directive * @return {?} */ function () { return !!this.mapComponent; }; /** * Sets heremap to polyline. This is called by map component so you don't need to call it manually. * @param {?} component map component * @param {?} map here map instance * @return {?} */ MapPolylineDirective.prototype.setMapComponent = /** * Sets heremap to polyline. This is called by map component so you don't need to call it manually. * @param {?} component map component * @param {?} map here map instance * @return {?} */ function (component, map) { var _this = this; this.mapComponent = component; this.proxy .then(function (mapObject) { return setTimeout(function () { if (mapObject instanceof H.map.Object) { map.addObject(mapObject); } }, _this.delay || 0); }); }; /** * @return {?} */ MapPolylineDirective.prototype.ngOnDestroy = /** * @return {?} */ function () { var _this = this; this.proxy .then(function (p) { _this.mapComponent .getMap() .then(function (map) { map.removeObject(_this.polyline); _this.polyline.dispose(); delete _this.polyline; }); }); }; MapPolylineDirective.decorators = [ { type: Directive, args: [{ selector: 'map-polyline', providers: [{ provide: BaseMapComponent, useExisting: forwardRef(function () { return MapPolylineDirective; }) }] },] } ]; /** @nocollapse */ MapPolylineDirective.ctorParameters = function () { return [ { type: HereMapsManager, }, ]; }; MapPolylineDirective.propDecorators = { "fillColor": [{ type: Input },], "strokeColor": [{ type: Input },], "lineWidth": [{ type: Input },], "options": [{ type: Input },], }; return MapPolylineDirective; }(BaseMapComponent)); export { MapPolylineDirective }; function MapPolylineDirective_tsickle_Closure_declarations() { /** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */ MapPolylineDirective.decorators; /** * @nocollapse * @type {function(): !Array<(null|{type: ?, decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>)})>} */ MapPolylineDirective.ctorParameters; /** @type {!Object<string,!Array<{type: !Function, args: (undefined|!Array<?>)}>>} */ MapPolylineDirective.propDecorators; /** @type {?} */ MapPolylineDirective.prototype.mapComponent; /** @type {?} */ MapPolylineDirective.prototype.polyline; /** @type {?} */ MapPolylineDirective.prototype._fillColor; /** @type {?} */ MapPolylineDirective.prototype._strokeColor; /** @type {?} */ MapPolylineDirective.prototype._lineWidth; } //# sourceMappingURL=map-polyline.js.map