import { Component , OnInit , ViewRef } from '@angular/core' ; import { HsConfig } from './../../config.service' ; import { HsCoreService } from './../core/core.service' ; import { HsLanguageService } from '../language/language.service' ; import { HsLayerUtilsService } from '../utils/layer-utils.service' ; import { HsLayoutService } from '../layout/layout.service' ; import { HsMapService } from './../map/map.service' ; import { HsPanelBaseComponent } from '../layout/panels/panel-base.component' ; import { HsSidebarService } from '../sidebar/sidebar.service' ; import { HsTripPlannerService , Waypoint } from './trip-planner.service' ; import { HsUtilsService } from '../utils/utils.service' ; import { setHighlighted } from '../../common/feature-extensions' ; @ Component ( { selector : 'hs-trip-planner' , templateUrl : './trip_planner.html' , } ) export class HsTripPlannerComponent extends HsPanelBaseComponent implements OnInit { loaderImage : string ; timer : any ; name = 'tripPlanner' ; constructor ( public HsMapService , public HsCoreService , public HsTripPlannerService , public HsConfig , hsLayoutService , public HsUtilsService , public HsLayerUtilsService , hsLanguageService , hsSidebarService ) { super ( hsLayoutService ) ; hsSidebarService . buttons . push ( { panel : 'tripPlanner' , module : 'hs-trip-planner' , order : 17 , fits : true , title : ( ) => hsLanguageService . getTranslation ( 'PANEL_HEADER.TRIP_PLANNER' ) , description : ( ) => hsLanguageService . getTranslation ( 'SIDEBAR.descriptions.TRIP_PLANNER' ) , icon : 'icon-sextant' , } ) ; } ngOnInit ( ) { if ( this . HsConfig . default_layers === undefined ) { this . HsConfig . default_layers = [ ] ; } else { this . HsConfig . default_layers . push ( this . HsTripPlannerService . routeLayer ) ; } this . HsTripPlannerService . fillVectorLayers ( ) ; } param { float } wp returns { string } formatDistance ( wp ) { return this . HsTripPlannerService . formatDistance ( wp ) ; } returns { string } totalDistance ( ) { let tmp = 0 ; this . HsTripPlannerService . waypoints . forEach ( ( wp ) => { if ( wp . routes . from ) { tmp += wp . routes . from . get ( 'summary' ) . distance / 1000.0 ; } } ) ; return tmp . toFixed ( 2 ) + 'km' ; } param { object } waypoint toggleEdit ( waypoint ) { waypoint . editMode = ! waypoint . editMode ; const src = this . HsTripPlannerService . waypointLayer . getSource ( ) ; setHighlighted ( src . getFeatureById ( waypoint . featureId ) , waypoint . editMode ) ; } }