UNPKG

ng2-heremaps

Version:
5 lines 28.4 kB
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("ng2-heremaps",["exports","@angular/core"],factory):factory((global.ng=global.ng||{},global.ng["ng2-heremaps"]={}),global.ng.core)}(this,function(exports,core){"use strict";var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])};function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}var __assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i<n;i++)for(var p in s=arguments[i])Object.prototype.hasOwnProperty.call(s,p)&&(t[p]=s[p]);return t},BaseMapComponent=function(){function BaseMapComponent(){var _this=this;this.proxy=new Promise(function(resolve){return _this.proxyResolver=resolve})}return BaseMapComponent.prototype.hasMapComponent=function(){return!1},BaseMapComponent.prototype.setMapComponent=function(component,map,ui){},BaseMapComponent}(),LAZY_LOADER_OPTIONS=new core.InjectionToken("_heremaps.LazyMapLoaderApiOptions"),BaseMapsApiLoader=function(){},ScriptLoaderProtocol={AUTO:"auto",HTTP:"http",HTTPS:"https"},LazyMapsApiLoader=function(_super){function LazyMapsApiLoader(options){var _this=_super.call(this)||this;_this.platformReady=new Promise(function(resolve,reject){_this._rejectPlatform=reject,_this._resolvePlatform=resolve}),_this._initialized=!1,_this._modules=new Map([["core",["js"]],["service",["js"]],["mapevents",["js"]],["ui",["js","css"]],["clustering",["js"]],["data",["js"]],["places",["js"]],["pano",["js"]]]),_this._options=Object.assign({},{apiKey:"",appId:"",apiVersion:"3.0",protocol:ScriptLoaderProtocol.AUTO,libraries:[]},options);var libs=_this._options.libraries.filter(function(l){return"core"!==l&&"service"!==l});return _this._options.libraries=["service"].concat(libs),_this}return __extends(LazyMapsApiLoader,_super),LazyMapsApiLoader.prototype.load=function(){var _this=this;return!1===this._initialized&&this.loadModules().then(function(_){var platform=new H.service.Platform({app_id:_this._options.appId,app_code:_this._options.apiKey,useHTTPS:"https:"===document.location.protocol});_this._resolvePlatform(platform)}).catch(function(error){_this._rejectPlatform(error)}),this.platformReady},LazyMapsApiLoader.prototype.loadModules=function(){var _this=this;return this.loadModule("core").then(function(){return Promise.all(_this._options.libraries.reduce(_this.distinct,[]).map(function(moduleName){return _this.loadModule(moduleName)}))})},LazyMapsApiLoader.prototype.loadModule=function(moduleName){var _this=this,mod=this._modules.get(moduleName);if(void 0===mod){var error=new Error("Unknown module "+moduleName);return Promise.reject(error)}return-1<mod.indexOf("css")&&document.body.appendChild(this.createStylesheet(moduleName)),new Promise(function(resolve,reject){var el=_this.createScript(moduleName,resolve,reject);document.body.appendChild(el)})},LazyMapsApiLoader.prototype.createStylesheet=function(moduleName){var element=document.createElement("link");return element.rel="stylesheet",element.href=this.createModuleUrl(moduleName,"css"),void 0!==console&&(element.onerror=console.error.bind(console)),element},LazyMapsApiLoader.prototype.createScript=function(moduleName,onLoad,onError){var script=document.createElement("script");return script.type="text/javascript",script.src=this.createModuleUrl(moduleName,"js"),script.async=!0,script.defer=!0,script.addEventListener("error",onError),script.addEventListener("load",onLoad),script},LazyMapsApiLoader.prototype.createModuleUrl=function(module,ext){void 0===ext&&(ext="js");return"https://js.api.here.com/v3/"+this._options.apiVersion+"/mapsjs-"+module+"."+ext},LazyMapsApiLoader.prototype.distinct=function(acc,next){return-1<acc.indexOf(next)?acc:acc.concat([next])},LazyMapsApiLoader.decorators=[{type:core.Injectable}],LazyMapsApiLoader.ctorParameters=function(){return[{type:void 0,decorators:[{type:core.Inject,args:[LAZY_LOADER_OPTIONS]}]}]},LazyMapsApiLoader}(BaseMapsApiLoader),DefaultCoords={latitude:40.73061,longitude:-73.935242}; /** * @license ng2-heremaps * MIT license */function noop(){}var HereMapsManager=function(){function HereMapsManager(loader){this.loader=loader,this._maps=new Map,this.getBrowserLocation().then(noop),this._loadPromise=this.loader.load()}return HereMapsManager.prototype.onApiLoad=function(){return this.loader.platformReady},HereMapsManager.prototype.createMarker=function(options){return this.loader.platformReady.then(function(){return new H.map.Marker(options.position)})},HereMapsManager.prototype.createBubble=function(options){return this.loader.platformReady.then(function(){return new H.ui.InfoBubble(options.position)})},HereMapsManager.prototype.getDirections=function(origin,destination,intermediatePoints){var _this=this;return void 0===intermediatePoints&&(intermediatePoints=[]),this.loader.platformReady.then(function(platform){var router=platform.getRoutingService();return new Promise(function(resolve,reject){var params={mode:"balanced;truck",representation:"navigation"},waypoints=[origin].concat(intermediatePoints,[destination]);waypoints.forEach(function(waypoint,index){return params["waypoint"+index]=_this.generateWaypointParam(waypoint,0===index||index===waypoints.length-1)}),router.calculateRoute(params,function(result){return resolve(result)},function(error){console.error({message:"fail to get directions",error:error}),reject(error)})})})},HereMapsManager.prototype.createMap=function(el,options,controls){var _this=this;return this.loader.platformReady.then(function(platform){var defaultLayers=_this._defaultLayers||platform.createDefaultLayers();_this._defaultLayers=defaultLayers;var map=new H.Map(el,defaultLayers.normal.map,options),ui=H.ui.UI.createDefault(map,defaultLayers,"en-US");ui.setUnitSystem(H.ui.UnitSystem.IMPERIAL);var mapEvents=new H.mapevents.MapEvents(map),behavior=new H.mapevents.Behavior(mapEvents);return controls&&(controls.mapTypeControl||ui.removeControl("mapsettings"),controls.zoomControl||ui.removeControl("zoom"),controls.scaleControl||ui.removeControl("scalebar"),!controls.streetViewControl&&H.PanoramaView&&ui.removeControl("panorama"),controls.scrollwheel||behavior.disable(H.mapevents.Behavior.WHEELZOOM),controls.enableDoubleClickZoom||behavior.disable(H.mapevents.Behavior.DBLTAPZOOM),controls.draggable||behavior.disable(H.mapevents.Behavior.DRAGGING)),{map:map,ui:ui,platform:platform}})},HereMapsManager.prototype.getMap=function(name){var _this=this;return this._loadPromise.then(function(){return _this._maps.get(name)})},HereMapsManager.prototype.addMap=function(name,map){this._maps.set(name,map)},HereMapsManager.prototype.removeMap=function(name){return this._maps.delete(name)},HereMapsManager.prototype.getBrowserLocation=function(){return this._browserLocationPromise?this._browserLocationPromise:this._browserLocationPromise=new Promise(function(resolve){"https"===location.protocol&&navigator.geolocation?navigator.geolocation.getCurrentPosition(function(success){resolve(success.coords)},function(error){console.error(error),1!==error.code&&console.warn("Permission is accepted but error encounter with message: "+error.message),resolve(DefaultCoords)}):resolve(DefaultCoords)})},HereMapsManager.prototype.calculateMapBounds=function(points){return void 0===points&&(points=[]),this.loader.platformReady.then(function(_){var bounds=(new H.map.Group).getBounds();return points&&1<points.length&&points.forEach(function(m){m instanceof H.map.AbstractMarker?bounds.mergePoint(m.getPosition()):bounds.mergePoint({lat:void 0!==m.latitude?m.latitude:m.lat,lng:void 0!==m.longitude?m.longitude:m.lng})}),Promise.resolve(bounds)})},HereMapsManager.prototype.generateWaypointParam=function(coordinates,end){return void 0===end&&(end=!1),"geo!"+(end?"stopOver":"passThrough")+"!"+(coordinates.lat||coordinates.latitude||0)+","+(coordinates.lng||coordinates.longitude||coordinates.lon||0)},HereMapsManager.decorators=[{type:core.Injectable}],HereMapsManager.ctorParameters=function(){return[{type:LazyMapsApiLoader}]},HereMapsManager}(),MapUIService=function(){function MapUIService(mapManager){var _this=this;this.mapManager=mapManager,this.ui=new Promise(function(resolve){_this.setUi=resolve})}return MapUIService.decorators=[{type:core.Injectable}],MapUIService.ctorParameters=function(){return[{type:HereMapsManager}]},MapUIService}();function toLatLng(geoPoint){return geoPoint?{lat:"lat"in geoPoint?geoPoint.lat:geoPoint.latitude,lng:"lng"in geoPoint?geoPoint.lng:"lon"in geoPoint?geoPoint.lon:geoPoint.longitude}:{lat:0,lng:0}}var MapComponent=function(){function MapComponent(_name,_elem,_mapsManager){var _this=this;this._name=_name,this._elem=_elem,this._mapsManager=_mapsManager,this.ui=new Promise(function(resolve){return _this._uiResolver=resolve}),this.autoFitMarkers=!0,this.enableDoubleClickZoom=!0,this.draggable=!0,this.keyboardShortcuts=!0,this.scrollwheel=!0,this.zoom=5,this.disableDefaultUI=!1,this.mapTypeControl=!1,this.rotateControl=!1,this.scaleControl=!0,this.streetViewControl=!1,this.animateZoom=!0,this.zoomControl=!0,this.update=new core.EventEmitter,this.clickMap=new core.EventEmitter,this._id=MapComponent.counters++,this._map=new Promise(function(resolve){return _this._mapResolver=resolve})}return Object.defineProperty(MapComponent.prototype,"backgroundColor",{set:function(value){this._mapBackgroundColor?console.warn('Option "backgroundColor" can only be set when the map is initialized'):this._mapBackgroundColor=value},enumerable:!0,configurable:!0}),Object.defineProperty(MapComponent.prototype,"center",{get:function(){return this._center},set:function(value){if(value){var mapCenter=toLatLng(value);this._map.then(function(map){mapCenter.lat&&mapCenter.lng&&map.setCenter(toLatLng(value))}),mapCenter.lat&&mapCenter.lng&&(this._center=toLatLng(value))}},enumerable:!0,configurable:!0}),MapComponent.prototype.getMap=function(){return this._map},MapComponent.prototype.ngOnInit=function(){var _this=this;this._mapsManager.createMap(this._elem.nativeElement.querySelector(".heremap-container"),this.getOptions(),this.getControlOptions()).then(function(_a){var map=_a.map,ui=_a.ui;_a.platform;_this._mapsManager.addMap(_this.toString(),map),_this._uiResolver(ui),_this._mapResolver(map),_this.attachEvents(map)})},MapComponent.prototype.ngOnDestroy=function(){this._mapsManager.removeMap(this.toString()),this._mapComponentsSubscriptions.unsubscribe()},MapComponent.prototype.ngAfterContentInit=function(){var _this=this;this._mapComponentsSubscriptions=this.mapComponents.changes.subscribe(function(){_this.attachComponentsToMap()}),this.attachComponentsToMap()},MapComponent.prototype.toString=function(){return this._name?this._name:"fh.here-maps-"+this._id},MapComponent.prototype.fitBounds=function(bounds){this.resetMapBounds(bounds)},MapComponent.prototype.attachComponentsToMap=function(){var _this=this;this._map.then(function(map){_this.ui.then(function(ui){_this.mapComponents.filter(function(v){return!v.hasMapComponent()}).forEach(function(v){v.setMapComponent(_this,map,ui)})})})},MapComponent.prototype.getOptions=function(){return{center:this.center?this.latLngCenter():{lat:0,lng:0},zoom:this.zoom||5}},MapComponent.prototype.getControlOptions=function(){return{mapTypeControl:this.mapTypeControl,rotateControl:this.rotateControl,scaleControl:this.scaleControl,streetViewControl:this.streetViewControl,zoomControl:this.zoomControl,enableDoubleClickZoom:this.enableDoubleClickZoom,draggable:this.draggable,keyboardShortcuts:this.keyboardShortcuts,scrollwheel:this.scrollwheel}},MapComponent.prototype.resetMapBounds=function(bounds){var _this=this;this._map.then(function(map){map.setViewBounds(bounds,_this.animateZoom)})},MapComponent.prototype.attachEvents=function(map){var _this=this;map.addEventListener("mapviewchangeend",function(){_this.update.emit(map)}),map.addEventListener("tap",function(e){var pointer=e.currentPointer,coordinates=map.screenToGeo(pointer.viewportX,pointer.viewportY);_this.clickMap.emit(__assign({},e,{coordinates:coordinates}))})},MapComponent.prototype.latLngCenter=function(){return{lat:this.center.lat?this.center.lat:this.center.latitude,lng:this.center.lng?this.center.lng:this.center.longitude}},MapComponent.counters=0,MapComponent.decorators=[{type:core.Component,args:[{selector:"heremap",template:'\n <div class="heremap-container" style="width: inherit; height: inherit"></div>\n <ng-content></ng-content>\n ',providers:[{provide:MapUIService,useClass:MapUIService}],styles:[":host {width: 100%; height: 100%}"]}]}],MapComponent.ctorParameters=function(){return[{type:void 0,decorators:[{type:core.Attribute,args:["name"]}]},{type:core.ElementRef},{type:HereMapsManager}]},MapComponent.propDecorators={mapComponents:[{type:core.ContentChildren,args:[core.forwardRef(function(){return BaseMapComponent}),{}]}],autoFitMarkers:[{type:core.Input}],backgroundColor:[{type:core.Input}],center:[{type:core.Input}],enableDoubleClickZoom:[{type:core.Input}],draggable:[{type:core.Input}],keyboardShortcuts:[{type:core.Input}],scrollwheel:[{type:core.Input}],zoom:[{type:core.Input}],minZoom:[{type:core.Input}],maxZoom:[{type:core.Input}],disableDefaultUI:[{type:core.Input}],mapTypeControl:[{type:core.Input}],rotateControl:[{type:core.Input}],scaleControl:[{type:core.Input}],streetViewControl:[{type:core.Input}],animateZoom:[{type:core.Input}],zoomControl:[{type:core.Input}],update:[{type:core.Output}],clickMap:[{type:core.Output}]},MapComponent}(),MapDirectionsDirective=function(_super){function MapDirectionsDirective(_mapsManager){var _this=_super.call(this)||this;return _this._mapsManager=_mapsManager,_this.directions_changed=new core.EventEmitter,_this.preserveViewport=!0,_this._intermediatePoints=[],_this._mapsManager.onApiLoad().then(function(){var lineString=new H.geo.LineString([44.09,-116.9,3e3,44.082305,-116.776059,2e3]),route=new H.map.Polyline(lineString);_this.proxyResolver(route)}),_this}return __extends(MapDirectionsDirective,_super),Object.defineProperty(MapDirectionsDirective.prototype,"route",{get:function(){return this._route},set:function(value){this._route!==value&&(this._route=value,this.tryShowRoute())},enumerable:!0,configurable:!0}),Object.defineProperty(MapDirectionsDirective.prototype,"origin",{get:function(){return this._origin},set:function(value){this._origin!==value&&(this._origin=value,this.tryShowRoute())},enumerable:!0,configurable:!0}),Object.defineProperty(MapDirectionsDirective.prototype,"destination",{get:function(){return this._destination},set:function(value){this._destination!==value&&(this._destination=value,this.tryShowRoute())},enumerable:!0,configurable:!0}),Object.defineProperty(MapDirectionsDirective.prototype,"intermediatePoints",{get:function(){return this._intermediatePoints},set:function(value){this._intermediatePoints!==value&&(this._intermediatePoints=value,this.tryShowRoute())},enumerable:!0,configurable:!0}),Object.defineProperty(MapDirectionsDirective.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(value){var _this=this;this._lineWidth!==value&&(this._lineWidth=value,this.proxy.then(function(route){var style=route.getStyle();(style=new H.map.SpatialStyle).lineWidth=_this._lineWidth,route.setStyle(style)}))},enumerable:!0,configurable:!0}),Object.defineProperty(MapDirectionsDirective.prototype,"strokeColor",{get:function(){return this._strokeColor},set:function(value){this._strokeColor!==value&&(this._strokeColor=value,this.proxy.then(function(route){var style=route.getStyle();(style=new H.map.SpatialStyle).strokeColor=value,route.setStyle(style)}))},enumerable:!0,configurable:!0}),Object.defineProperty(MapDirectionsDirective.prototype,"fillColor",{get:function(){return this._fillColor},set:function(value){this._fillColor!==value&&(this._fillColor=value,this.proxy.then(function(route){var style=route.getStyle();(style=new H.map.SpatialStyle).fillColor=value,route.setStyle(style)}))},enumerable:!0,configurable:!0}),MapDirectionsDirective.prototype.hasMapComponent=function(){return!!this.mapComponent},MapDirectionsDirective.prototype.setMapComponent=function(component,map,ui){var _this=this;this.mapComponent=component,this.proxy.then(function(mapObject){return setTimeout(function(){mapObject instanceof H.map.Object&&map.addObject(mapObject)},_this.delay||0)})},MapDirectionsDirective.prototype.ngOnDestroy=function(){var _this=this;this.mapComponent.getMap().then(function(map){_this.proxy.then(function(polyline){polyline.dispose()})})},MapDirectionsDirective.prototype.tryShowRoute=function(){var _this=this,route=this._route||[];route instanceof Array&&0<route.length?this.renderRoute(route):this.origin&&this.destination?(this.renderRoute([]),this._mapsManager.getDirections(toLatLng(this.origin),toLatLng(this.destination),this.intermediatePoints||[]).then(function(r){if(r&&r.response&&r.response.route){var newRoute=r.response.route[0].shape.map(function(str){var parts=str.split(",");return{lat:parseFloat(parts[0]),lng:parseFloat(parts[1])}});_this.renderRoute(newRoute||[])}else _this.renderRoute([])}).catch(function(e){_this.renderRoute([])})):this.renderRoute([])},MapDirectionsDirective.prototype.renderRoute=function(route){this.proxy.then(function(polyline){if(route instanceof Array&&0<route.length){var lineString_1=new H.geo.LineString([]);route.forEach(function(point){lineString_1.pushPoint(toLatLng(point))}),polyline.setGeometry(lineString_1),polyline.setVisibility(0<route.length)}else polyline.setVisibility(!1)})},MapDirectionsDirective.prototype.bindEvents=function(){},MapDirectionsDirective.decorators=[{type:core.Directive,args:[{selector:"map-directions",providers:[{provide:BaseMapComponent,useExisting:core.forwardRef(function(){return MapDirectionsDirective})}]}]}],MapDirectionsDirective.ctorParameters=function(){return[{type:HereMapsManager}]},MapDirectionsDirective.propDecorators={route:[{type:core.Input}],origin:[{type:core.Input}],destination:[{type:core.Input}],intermediatePoints:[{type:core.Input}],directions_changed:[{type:core.Output}],preserveViewport:[{type:core.Input}]},MapDirectionsDirective}(BaseMapComponent),MapMakerDirective=function(_super){function MapMakerDirective(_mapsManager){var _this=_super.call(this)||this;return _this._mapsManager=_mapsManager,_this.click=new core.EventEmitter,_this.dblclick=new core.EventEmitter,_this.rightclick=new core.EventEmitter,_this.position_changed=new core.EventEmitter,_this.icon_changed=new core.EventEmitter,_this.title_changed=new core.EventEmitter,_this.visible_changed=new core.EventEmitter,_this._clickable=!0,_this}return __extends(MapMakerDirective,_super),Object.defineProperty(MapMakerDirective.prototype,"position",{set:function(point){var _this=this,position=toLatLng(point);this._mapsManager.createMarker({position:position}).then(function(marker){_this.bindEvents(marker),_this.proxyResolver(marker)}),this.proxy.then(function(marker){marker.setPosition(toLatLng(point))})},enumerable:!0,configurable:!0}),Object.defineProperty(MapMakerDirective.prototype,"clickable",{set:function(mode){this._clickable=mode},enumerable:!0,configurable:!0}),Object.defineProperty(MapMakerDirective.prototype,"icon",{set:function(value){this.proxy.then(function(marker){"string"==typeof value&&(value=new H.map.Icon(value,{size:{w:20,h:20},crossOrigin:!1})),marker.setIcon(value)})},enumerable:!0,configurable:!0}),Object.defineProperty(MapMakerDirective.prototype,"opacity",{set:function(value){},enumerable:!0,configurable:!0}),Object.defineProperty(MapMakerDirective.prototype,"title",{set:function(value){},enumerable:!0,configurable:!0}),Object.defineProperty(MapMakerDirective.prototype,"visible",{set:function(mode){this.proxy.then(function(marker){return marker.setVisibility(mode)})},enumerable:!0,configurable:!0}),Object.defineProperty(MapMakerDirective.prototype,"zIndex",{set:function(value){this.proxy.then(function(marker){return marker.setZIndex(value)})},enumerable:!0,configurable:!0}),Object.defineProperty(MapMakerDirective.prototype,"setDelay",{set:function(value){this.delay=value},enumerable:!0,configurable:!0}),MapMakerDirective.prototype.ngOnDestroy=function(){var _this=this;this.proxy.then(function(marker){marker.dispose(),_this.mapComponent.getMap().then(function(map){0<=map.getObjects().indexOf(marker)&&map.removeObject(marker)})})},MapMakerDirective.prototype.hasMapComponent=function(){return!!this.mapComponent},MapMakerDirective.prototype.setMapComponent=function(component,map,ui){var _this=this;this.mapComponent=component,this.proxy.then(function(mapObject){return setTimeout(function(){mapObject instanceof H.map.Object&&map.addObject(mapObject)},_this.delay||0)})},MapMakerDirective.prototype.bindEvents=function(marker){var _this=this;marker.addEventListener("tap",function(e){_this._clickable&&_this.click.emit(e)}),marker.addEventListener("dbltap",function(e){_this._clickable&&_this.dblclick.emit(e)}),marker.addEventListener("visibilitychange",function(e){return _this.visible_changed.emit(e)})},MapMakerDirective.decorators=[{type:core.Directive,args:[{selector:"map-marker",providers:[{provide:BaseMapComponent,useExisting:core.forwardRef(function(){return MapMakerDirective})}]}]}],MapMakerDirective.ctorParameters=function(){return[{type:HereMapsManager}]},MapMakerDirective.propDecorators={click:[{type:core.Output}],dblclick:[{type:core.Output}],rightclick:[{type:core.Output}],position_changed:[{type:core.Output}],icon_changed:[{type:core.Output}],title_changed:[{type:core.Output}],visible_changed:[{type:core.Output}],position:[{type:core.Input}],clickable:[{type:core.Input}],icon:[{type:core.Input}],opacity:[{type:core.Input}],title:[{type:core.Input}],visible:[{type:core.Input}],zIndex:[{type:core.Input}],setDelay:[{type:core.Input,args:["delay"]}]},MapMakerDirective}(BaseMapComponent),MapPolylineDirective=function(_super){function MapPolylineDirective(mapsManager){var _this=_super.call(this)||this;return _this._lineWidth=4,mapsManager.onApiLoad().then(function(){var strip=new H.geo.Strip;_this.polyline=new H.map.Polyline(strip),_this.proxyResolver(_this.polyline)}),_this}return __extends(MapPolylineDirective,_super),Object.defineProperty(MapPolylineDirective.prototype,"fillColor",{get:function(){return this._fillColor},set:function(color){this._fillColor!==color&&(this._fillColor=color,this.proxy.then(function(p){var style=Object.assign({},p.getStyle());style.fillColor=color,p.setStyle(style)}))},enumerable:!0,configurable:!0}),Object.defineProperty(MapPolylineDirective.prototype,"strokeColor",{get:function(){return this._strokeColor},set:function(color){this._strokeColor!==color&&(this._strokeColor=color,this.proxy.then(function(p){var style=Object.assign({},p.getStyle());style.strokeColor=color,p.setStyle(style)}))},enumerable:!0,configurable:!0}),Object.defineProperty(MapPolylineDirective.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(lineWidth){this._lineWidth!==lineWidth&&(this._lineWidth=lineWidth,this.proxy.then(function(p){var style=Object.assign({},p.getStyle());style.lineWidth=lineWidth,p.setStyle(style)}))},enumerable:!0,configurable:!0}),Object.defineProperty(MapPolylineDirective.prototype,"options",{set:function(opts){var _this=this;this.proxy.then(function(polyline){var style={strokeColor:opts.strokeColor||_this.strokeColor,fillColor:opts.fillColor||_this.fillColor,lineWidth:opts.lineWidth||_this.lineWidth},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:!0,configurable:!0}),MapPolylineDirective.prototype.hasMapComponent=function(){return!!this.mapComponent},MapPolylineDirective.prototype.setMapComponent=function(component,map){var _this=this;this.mapComponent=component,this.proxy.then(function(mapObject){return setTimeout(function(){mapObject instanceof H.map.Object&&map.addObject(mapObject)},_this.delay||0)})},MapPolylineDirective.prototype.ngOnDestroy=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:core.Directive,args:[{selector:"map-polyline",providers:[{provide:BaseMapComponent,useExisting:core.forwardRef(function(){return MapPolylineDirective})}]}]}],MapPolylineDirective.ctorParameters=function(){return[{type:HereMapsManager}]},MapPolylineDirective.propDecorators={fillColor:[{type:core.Input}],strokeColor:[{type:core.Input}],lineWidth:[{type:core.Input}],options:[{type:core.Input}]},MapPolylineDirective}(BaseMapComponent),NoopMapsApiLoader=function(){function NoopMapsApiLoader(){var _this=this;this.platformReady=new Promise(function(resolve,reject){_this._rejectPlatform=reject,_this._resolvePlatform=resolve})}return NoopMapsApiLoader.prototype.load=function(){return H&&H.service&&H.service.Platform?Promise.resolve():Promise.reject(new Error("Here Maps API not loaded on page. Make sure window.H.service.Platform is available!"))},NoopMapsApiLoader}(),MapBubbleDirective=function(_super){function MapBubbleDirective(_mapsManager){var _this=_super.call(this)||this;return _this._mapsManager=_mapsManager,_this.click=new core.EventEmitter,_this._clickable=!0,_this}return __extends(MapBubbleDirective,_super),Object.defineProperty(MapBubbleDirective.prototype,"position",{set:function(point){var _this=this,position=toLatLng(point);this._mapsManager.createBubble({position:position}).then(function(bubble){_this.bindEvents(bubble),_this.proxyResolver(bubble)}),this.proxy.then(function(bubble){bubble.setPosition(toLatLng(point))})},enumerable:!0,configurable:!0}),Object.defineProperty(MapBubbleDirective.prototype,"clickable",{set:function(mode){this._clickable=mode},enumerable:!0,configurable:!0}),Object.defineProperty(MapBubbleDirective.prototype,"contentElement",{set:function(value){this.proxy.then(function(bubble){return bubble.setContent(value)})},enumerable:!0,configurable:!0}),MapBubbleDirective.prototype.hasMapComponent=function(){return!!this.mapComponent},MapBubbleDirective.prototype.setMapComponent=function(component,map,ui){var _this=this;this.mapComponent=component,this.proxy.then(function(mapObject){return setTimeout(function(){mapObject instanceof H.ui.InfoBubble&&ui.addBubble(mapObject)},_this.delay||0)})},MapBubbleDirective.prototype.bindEvents=function(marker){var _this=this;marker.addEventListener("tap",function(e){_this._clickable&&_this.click.emit(e)})},MapBubbleDirective.decorators=[{type:core.Directive,args:[{selector:"map-bubble",providers:[{provide:BaseMapComponent,useExisting:core.forwardRef(function(){return MapBubbleDirective})}]}]}],MapBubbleDirective.ctorParameters=function(){return[{type:HereMapsManager}]},MapBubbleDirective.propDecorators={click:[{type:core.Output}],position:[{type:core.Input}],clickable:[{type:core.Input}],contentElement:[{type:core.Input}]},MapBubbleDirective}(BaseMapComponent),HereMapsModule=function(){function HereMapsModule(){}return HereMapsModule.forRoot=function(loaderOptions){return{ngModule:HereMapsModule,providers:[{provide:LAZY_LOADER_OPTIONS,useValue:loaderOptions},LazyMapsApiLoader,HereMapsManager]}},HereMapsModule.decorators=[{type:core.NgModule,args:[{declarations:[MapComponent,MapDirectionsDirective,MapMakerDirective,MapPolylineDirective,MapBubbleDirective],exports:[MapComponent,MapDirectionsDirective,MapMakerDirective,MapPolylineDirective,MapBubbleDirective]}]}],HereMapsModule}();exports.BaseMapComponent=BaseMapComponent,exports.MapComponent=MapComponent,exports.MapDirectionsDirective=MapDirectionsDirective,exports.MapMakerDirective=MapMakerDirective,exports.MapPolylineDirective=MapPolylineDirective,exports.BaseMapsApiLoader=BaseMapsApiLoader,exports.LAZY_LOADER_OPTIONS=LAZY_LOADER_OPTIONS,exports.LazyMapsApiLoader=LazyMapsApiLoader,exports.HereMapsManager=HereMapsManager,exports.NoopMapsApiLoader=NoopMapsApiLoader,exports.Animation={BOUNCE:1,DROP:2},exports.ZoomLevel={World:1,Continent:5,City:10,Streets:15,Buildings:20},exports.MapUIService=MapUIService,exports.HereMapsModule=HereMapsModule,exports.ɵa=MapBubbleDirective,Object.defineProperty(exports,"__esModule",{value:!0})});