Skip to content

Commit 003ef57

Browse files
committed
fixed getTweetByDate
1 parent 829371a commit 003ef57

File tree

3 files changed

+19
-50
lines changed

3 files changed

+19
-50
lines changed

frontend/src/app/map/layers/FireTweetLayer.ts

-37
This file was deleted.

frontend/src/app/map/layers/fire.tweet.layer.ts

+15-10
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class FireTweetLayer {
2626

2727
constructor(private mainControl, private mapService: MapService, private map, private timeService: TimeService) {
2828
// This is the overlay controller defined in constructor
29-
//rewrite
29+
// rewrite
3030
this.mapService.getFireTweetData().subscribe(this.tweetDataHandler);
3131

3232
this.map.on('overlayadd', (event) => {
@@ -170,7 +170,7 @@ export class FireTweetLayer {
170170

171171
this.tweetData.forEach(tweet => {
172172
tempData.push([tweet.lat, tweet.long]);
173-
}
173+
}
174174
);
175175

176176
this.tweetLayer.setData(tempData);
@@ -187,12 +187,17 @@ export class FireTweetLayer {
187187
*/
188188
this.tempDataWithID = [];
189189
const [startDateInMs, endDateInMs] = this.timeService.getRangeDate();
190-
this.timeService.getTweetByDate(startDateInMs, endDateInMs).subscribe((data) => {
191-
console.log(data);
192-
this.tweetLayer.setData(data);
193-
});
194-
//console.log(startDateInMs);
195-
//console.log(this.timeService.getTweetByDate(startDateInMs, endDateInMs));
190+
this.timeService.getTweetByDate(startDateInMs, endDateInMs).subscribe(tweets => {
191+
const tempData = [];
192+
tweets.forEach(tweet => {
193+
tempData.push([tweet.lat, tweet.long]);
194+
}
195+
);
196+
this.tweetLayer.setData(tempData);
197+
}
198+
);
199+
// console.log(startDateInMs);
200+
// console.log(this.timeService.getTweetByDate(startDateInMs, endDateInMs));
196201

197202
// this.tweetData.forEach(tweet => {
198203
// const time = new Date(tweet.create_at).getTime();
@@ -201,8 +206,8 @@ export class FireTweetLayer {
201206
// this.tempDataWithID.push([tweet.lat, tweet.long, tweet.id]);
202207
// }
203208
// });
204-
//console.log(tempData);
205-
//this.tweetLayer.setData(tempData); //draw on twittermap
209+
// console.log(tempData);
210+
// this.tweetLayer.setData(tempData); //draw on twittermap
206211
}
207212

208213
idOverPoint(x, y) {

frontend/src/app/services/time/time.service.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {Injectable} from '@angular/core';
1212
import {Observable} from 'rxjs';
1313
import {environment} from '../../../environments/environment';
1414
import {HttpClient, HttpParams} from '@angular/common/http';
15+
import {Tweet} from "../../models/tweet.model";
1516

1617
// import {Observable, Subject, BehaviorSubject} from 'rxjs';
1718
// import {HttpClient, HttpParams} from '@angular/common/http';
@@ -52,9 +53,9 @@ export class TimeService {
5253
return [this.rangeStartDateInMS, this.rangeEndDateInMS];
5354
}
5455

55-
getTweetByDate(startDate, endDate): Observable<object> {
56-
return this.http.get<object>(`http://${environment.host}:${environment.port}/tweet/tweet-by-date`,
57-
{params: new HttpParams().set('start-date', startDate ).set('end-date', endDate)});
56+
getTweetByDate(startDate, endDate): Observable<Tweet[]> {
57+
return this.http.get<Tweet[]>(`http://${environment.host}:${environment.port}/tweet/tweet-by-date`,
58+
{params: new HttpParams().set('start-date', startDate).set('end-date', endDate)});
5859
}
5960
}
6061

0 commit comments

Comments
 (0)