This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<style> | |
body { | |
margin: 0px; | |
padding: 0px; | |
} | |
</style> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class City { | |
Rank?: number; | |
City?: string; | |
Latitude?: number; | |
Longitude?: number; | |
Population?: number; | |
Country?: string; | |
Place?: number; | |
Product?: number; | |
Programming?: number; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class DataService { | |
selectedCity = new Subject<City>(); | |
clearSelected = new Subject<boolean>(); | |
constructor(private http: HttpClient) {} | |
getData() { | |
return this.http.get('assets/data.csv', { responseType: 'text' }).pipe( | |
map((d) => this.convertToObject(d)) | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="search-list-container"> | |
<mat-form-field class="search-input"> | |
<mat-label>Search City or Country</mat-label> | |
<input matInput (keyup)="applyFilter($event)" /> | |
</mat-form-field> | |
<div class="search-list"> | |
<mat-selection-list #cityList [multiple]="false" (selectionChange)="selectedOption(cityList.selectedOptions.selected)"> | |
<mat-list-option | |
*ngFor="let city of cities | filter: searchTerm" | |
[value]="city" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class SearchListComponent implements OnInit { | |
@Input() | |
cities: City[] = []; | |
filteredCities: City[] = []; | |
searchTerm = ''; | |
selectedCity: City; | |
@ViewChild('cityList') cityList: MatSelectionList; | |
constructor(private dataService: DataService) {} | |
ngOnInit(): void { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div *ngIf="apiLoaded | async"> | |
<google-map #gmap width="100%" height="95vh" [center]="center" [options]="mapOptions"> | |
<map-marker | |
#marker="mapMarker" | |
*ngFor="let city of cities" | |
[position]="getMarkerPosition(city)" | |
[options]="markerOptions" | |
[label]="city?.Rank + ''" | |
[title]="city?.City + ''" | |
(mapClick)="openInfo(marker, city)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class MapComponent implements OnInit { | |
@Input() | |
cities: City[] = []; | |
apiLoaded: Observable<boolean>; | |
mapOptions: google.maps.MapOptions; | |
markerOptions: google.maps.MarkerOptions; | |
@ViewChild(MapInfoWindow) infoWindow: MapInfoWindow; | |
infoContent: City = {}; | |
center: google.maps.LatLng; | |
constructor(httpClient: HttpClient, private dataService: DataService) { |