import {Component, ViewEncapsulation} from '@angular/core'; import {ApiService} from '../api.service'; import {SimpleTable} from '../../theme/components/tables/simpleTable/simpleTable.component'; declare var google: any; interface IMapPoint { position: Object; icon: string; } @Component({ selector: 'digging', encapsulation: ViewEncapsulation.None, styles: [require('./digging.scss')], template: require('./digging.html'), providers: [SimpleTable] }) export class Digging { mapPoint: IMapPoint[] = []; Continuances: Object[] = []; District: Object[] = []; Performers: Object[] = []; Dynamic: Object[] = []; constructor(private _apiService: ApiService) { } ngOnInit() { this._apiService.getDiggingMapPoints().then(data => { data.forEach(item => { if (item.state == 0) { this.mapPoint.push({ position: new google.maps.LatLng(item.latitude, item.longitude), icon: '../../../assets/img/greenPoint.png' }); } else if (item.state == 1) { this.mapPoint.push({ position: new google.maps.LatLng(item.latitude, item.longitude), icon: '../../../assets/img/yellowPoint.png' }); } else { this.mapPoint.push({ position: new google.maps.LatLng(item.latitude, item.longitude), icon: '../../../assets/img/redPoint.png' }); } }); }) .then(() => { let mapProp = { center: new google.maps.LatLng(50.450090972, 30.523414806), zoom: 12 }; let map = new google.maps.Map(document.getElementById("map"), mapProp); let pointsLength = this.mapPoint.length for (let i = 0, feature; i < pointsLength; i++) { let marker = new google.maps.Marker({ position: this.mapPoint[i].position, icon: this.mapPoint[i].icon, map: map }) } }); this._apiService.getDiggingContinuances().then(data => { this.Continuances = data; }); this._apiService.getDiggingDistrict().then(data => { this.District = data; }); this._apiService.getDiggingPerformers().then(data => { this.Performers = data; }); this._apiService.getDiggingDynamic().then(data => { this.Dynamic = data; }); } };