diff --git a/src/app/pages/maps/gmaps/gmaps.component.ts b/src/app/pages/maps/gmaps/gmaps.component.ts index c60a3650..51da4857 100644 --- a/src/app/pages/maps/gmaps/gmaps.component.ts +++ b/src/app/pages/maps/gmaps/gmaps.component.ts @@ -3,7 +3,7 @@ import { Component } from '@angular/core'; @Component({ selector: 'ngx-gmaps', styleUrls: ['./gmaps.component.scss'], - templateUrl: './gmaps.component.html' + templateUrl: './gmaps.component.html', }) export class GmapsComponent { public readonly position = { lat: 51.678418, lng: 7.809007 }; diff --git a/src/app/pages/maps/search-map/entity/position.model.ts b/src/app/pages/maps/search-map/entity/position.model.ts index 26f1e3cb..c5f38f56 100644 --- a/src/app/pages/maps/search-map/entity/position.model.ts +++ b/src/app/pages/maps/search-map/entity/position.model.ts @@ -1,6 +1,6 @@ export class PositionModel { - constructor( - public lat = 53.9, - public lng = 27.5667, + public constructor( + public lat: number = 53.9, + public lng: number = 27.5667, ) {} } diff --git a/src/app/pages/maps/search-map/map/map.component.html b/src/app/pages/maps/search-map/map/map.component.html index c5f827e6..04331a29 100644 --- a/src/app/pages/maps/search-map/map/map.component.html +++ b/src/app/pages/maps/search-map/map/map.component.html @@ -1,7 +1,3 @@ - + + + \ No newline at end of file diff --git a/src/app/pages/maps/search-map/map/map.component.ts b/src/app/pages/maps/search-map/map/map.component.ts index 657c6fb8..b8d42cc3 100644 --- a/src/app/pages/maps/search-map/map/map.component.ts +++ b/src/app/pages/maps/search-map/map/map.component.ts @@ -7,18 +7,19 @@ import { PositionModel } from '../entity/position.model'; styleUrls: ['./map.component.scss'], }) export class MapComponent implements OnInit { - position: PositionModel = null; - zoom: number = 1; + public position: PositionModel = null; + public zoom: number = 1; @Input() public set searchedPosition(position: PositionModel) { - if (position) { - this.position = position; - this.zoom = 12; - } + if (!position) return; + + console.dir(position); + this.position = position; + this.zoom = 12; } - ngOnInit() { + public ngOnInit(): void { // set up current location if ('geolocation' in navigator) { navigator.geolocation.getCurrentPosition((position) => { diff --git a/src/app/pages/maps/search-map/search-map.component.ts b/src/app/pages/maps/search-map/search-map.component.ts index 43f66f8d..8fe5fbd6 100644 --- a/src/app/pages/maps/search-map/search-map.component.ts +++ b/src/app/pages/maps/search-map/search-map.component.ts @@ -6,9 +6,9 @@ import { PositionModel } from './entity/position.model'; templateUrl: './search-map.component.html', }) export class SearchMapComponent { - searchedPosition: PositionModel = new PositionModel(); + public searchedPosition: PositionModel = new PositionModel(); - setPosition(position: PositionModel) { + public setPosition(position: PositionModel): void { this.searchedPosition = position; } } diff --git a/src/app/pages/maps/search-map/search/search.component.ts b/src/app/pages/maps/search-map/search/search.component.ts index dca89a4d..28ee1fac 100644 --- a/src/app/pages/maps/search-map/search/search.component.ts +++ b/src/app/pages/maps/search-map/search/search.component.ts @@ -1,7 +1,5 @@ import { Component, ElementRef, EventEmitter, NgZone, OnInit, Output, ViewChild } from '@angular/core'; -// import { MapsAPILoader } from '@agm/core'; -import { Location } from '../entity/Location'; - +import { PositionModel } from '../entity/position.model'; @Component({ selector: 'ngx-search', @@ -9,36 +7,34 @@ import { Location } from '../entity/Location'; }) export class SearchComponent implements OnInit { - @Output() positionChanged = new EventEmitter(); + @Output() + public readonly positionChanged: EventEmitter = new EventEmitter(); @ViewChild('search', { static: true }) public searchElementRef: ElementRef; - constructor(// private mapsAPILoader: MapsAPILoader, - private ngZone: NgZone) { - } + constructor(private readonly ngZone: NgZone) {} ngOnInit() { - // load Places Autocomplete - // this.mapsAPILoader.load().then(() => { - // const autocomplete = new google.maps.places.Autocomplete(this.searchElementRef.nativeElement, { - // types: ['address'], - // }); - // autocomplete.addListener('place_changed', () => { - // this.ngZone.run(() => { - // // get the place result - // const place: google.maps.places.PlaceResult = autocomplete.getPlace(); + const autocomplete = new google.maps.places.Autocomplete( + this.searchElementRef.nativeElement, { types: ['address'] }, + ); - // // verify result - // if (place.geometry === undefined || place.geometry === null) { - // return; - // } + autocomplete.addListener('place_changed', () => { + this.ngZone.run(() => { + // get the place result + const place: google.maps.places.PlaceResult = autocomplete.getPlace(); - // this.positionChanged.emit( - // new Location(place.geometry.location.lat(), - // place.geometry.location.lng())); - // }); - // }); - // }); + // verify result + if (place.geometry === undefined || place.geometry === null) { + return; + } + + this.positionChanged.emit(new PositionModel( + place.geometry.location.lat(), + place.geometry.location.lng(), + )); + }); + }); } } diff --git a/src/app/pages/tables/smart-table/smart-table.component.ts b/src/app/pages/tables/smart-table/smart-table.component.ts index d14f8d17..164778cf 100644 --- a/src/app/pages/tables/smart-table/smart-table.component.ts +++ b/src/app/pages/tables/smart-table/smart-table.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core'; // import { LocalDataSource } from 'ng2-smart-table'; -import { SmartTableData } from '../../../@core/data/smart-table'; +// import { SmartTableData } from '../../../@core/data/smart-table'; @Component({ selector: 'ngx-smart-table', @@ -55,10 +55,10 @@ export class SmartTableComponent { // source: LocalDataSource = new LocalDataSource(); - constructor(private service: SmartTableData) { - // const data = this.service.getData(); - // this.source.load(data); - } + // constructor(private service: SmartTableData) { + // const data = this.service.getData(); + // this.source.load(data); + // } onDeleteConfirm(event): void { if (window.confirm('Are you sure you want to delete?')) { diff --git a/src/index.html b/src/index.html index 5ed7c8fa..5192560c 100644 --- a/src/index.html +++ b/src/index.html @@ -9,7 +9,7 @@ - + Loading...