import { Component , OnInit , Input , ChangeDetectionStrategy } from '@angular/core' ; import { NearbyCitiesService } from '../nearby-cities.service' ; import { RegionsService , PlacesService , Place } from 'hazdev-ng-geoserve-output' ; import { Event } from '../../event' ; @ Component ( { changeDetection : ChangeDetectionStrategy . OnPush , selector : 'region-info-display' , styleUrls : [ './region-info-display.component.scss' ] , templateUrl : './region-info-display.component.html' } ) export class RegionInfoDisplayComponent implements OnInit { coordinates : Place ; private _event : Event ; constructor ( public citiesService , public placesService , public regionsService ) { } /**
     * Return the current event object being rendered.
     */ get event ( ) : Event { return this . _event ; } param event { Event } @ Input ( ) set event ( ev ) { this . _event = ev ; if ( ! this . _event ) { return ; } if ( this . _event . geometry ) { this . coordinates = { latitude : this . _event . geometry . coordinates [ 1 ] , longitude : this . _event . geometry . coordinates [ 0 ] } ; } else { this . coordinates = null ; } const product = this . _event . getProduct ( 'nearby-cities' ) ; if ( product ) { this . getNearbyCities ( product ) ; } else { this . getPlaces ( this . coordinates ) ; } this . getRegions ( this . coordinates ) ; } getNearbyCities ( product ) { this . citiesService . get ( product ) ; } getPlaces ( coordinates ) { if ( coordinates && ( coordinates . latitude || coordinates . latitude === 0 ) && ( coordinates . longitude || coordinates . longitude === 0 ) ) { this . placesService . getPlaces ( coordinates . latitude , coordinates . longitude ) ; } } getRegions ( coordinates ) { if ( coordinates && ( coordinates . latitude || coordinates . latitude === 0 ) && ( coordinates . longitude || coordinates . longitude === 0 ) ) { this . regionsService . getRegions ( coordinates . latitude , coordinates . longitude ) ; } } ngOnInit ( ) { } }