Skip to content

Instantly share code, notes, and snippets.

View Gsync's full-sized avatar
💭
Working on Angular, React, aws, nodejs microservices

Khuram Niaz Gsync

💭
Working on Angular, React, aws, nodejs microservices
View GitHub Profile
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
margin: 0px;
padding: 0px;
}
</style>
</head>
export class City {
Rank?: number;
City?: string;
Latitude?: number;
Longitude?: number;
Population?: number;
Country?: string;
Place?: number;
Product?: number;
Programming?: number;
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))
);
}
<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"
export class SearchListComponent implements OnInit {
@Input()
cities: City[] = [];
filteredCities: City[] = [];
searchTerm = '';
selectedCity: City;
@ViewChild('cityList') cityList: MatSelectionList;
constructor(private dataService: DataService) {}
ngOnInit(): void {
<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)"
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) {