@@ -10,6 +10,7 @@ import { Router } from '@angular/router';
10
10
import { AirtableService } from '../../services/airtable.service' ;
11
11
import { MapBrowserEvent } from 'ol' ;
12
12
import { NgStyle } from "@angular/common" ;
13
+ import { Activity } from '../../types/activity.interface' ;
13
14
14
15
@Component ( {
15
16
selector : 'app-map' ,
@@ -38,6 +39,10 @@ export class MapComponent implements OnInit {
38
39
}
39
40
return false ;
40
41
}
42
+
43
+ getColor ( activity : Activity ) {
44
+ return this . getBookmarked ( activity . osm_id ) ? "gold" : activity . type . color
45
+ }
41
46
42
47
ngOnInit ( ) : void {
43
48
this . vectorSource = new VectorSource ( ) ;
@@ -67,21 +72,31 @@ export class MapComponent implements OnInit {
67
72
// INITIALIZE
68
73
69
74
this . airtableService . getActivityList ( ) . subscribe ( activities => {
70
- activities . forEach ( activity => {
75
+ // Ensure features are added to the vector source and the map is refreshed
76
+ activities . forEach ( ( activity ) => {
71
77
const feature = new Feature ( {
72
78
geometry : new Point ( fromLonLat ( [ activity . longitude , activity . latitude ] ) ) ,
73
- activity : activity
79
+ activity : activity ,
80
+ style : new Style ( {
81
+ image : new Icon ( {
82
+ src : 'data:image/svg+xml;utf8,' + activity . type . svg ,
83
+ color : this . getColor ( activity ) ,
84
+ size : [ this . iconSize , this . iconSize ]
85
+ } )
86
+ } )
74
87
} ) ;
75
-
88
+ this . vectorSource . addFeature ( feature ) ;
89
+ } ) ;
90
+ this . tooltip . nativeElement . style . display = 'none' ;
91
+ this . vectorSource . getFeatures ( ) . forEach ( ( feature : Feature < Geometry > ) => {
92
+ const activity = feature . get ( 'activity' ) ;
76
93
feature . setStyle ( new Style ( {
77
94
image : new Icon ( {
78
95
src : 'data:image/svg+xml;utf8,' + activity . type . svg ,
79
- color : activity . type . color ,
80
- size : [ this . iconSize , this . iconSize ]
96
+ color : this . getColor ( activity ) ,
97
+ scale : this . iconSize
81
98
} )
82
99
} ) ) ;
83
-
84
- this . vectorSource . addFeature ( feature ) ;
85
100
} ) ;
86
101
} ) ;
87
102
}
@@ -115,7 +130,7 @@ export class MapComponent implements OnInit {
115
130
( feature as Feature < Geometry > ) . setStyle ( new Style ( {
116
131
image : new Icon ( {
117
132
src : 'data:image/svg+xml;utf8,' + activity . type . svg ,
118
- color : activity . type . color ,
133
+ color : this . getColor ( activity ) ,
119
134
scale : this . iconSize ,
120
135
} )
121
136
} ) ) ;
@@ -131,7 +146,7 @@ export class MapComponent implements OnInit {
131
146
feature . setStyle ( new Style ( {
132
147
image : new Icon ( {
133
148
src : 'data:image/svg+xml;utf8,' + activity . type . svg ,
134
- color : activity . type . color ,
149
+ color : this . getColor ( activity ) ,
135
150
scale : this . iconSize
136
151
} )
137
152
} ) ) ;
0 commit comments