@@ -22,6 +22,7 @@ import { Activity } from '../../types/activity.interface';
22
22
styleUrls : [ './map.component.scss' ]
23
23
} )
24
24
export class MapComponent implements OnInit {
25
+ isLoading = true ;
25
26
map ! : Map ;
26
27
vectorSource ! : VectorSource ;
27
28
@@ -47,10 +48,12 @@ export class MapComponent implements OnInit {
47
48
}
48
49
49
50
ngOnInit ( ) : void {
51
+ this . isLoading = true ;
50
52
this . vectorSource = new VectorSource ( ) ;
51
53
const vectorLayer = new VectorLayer ( {
52
54
source : this . vectorSource
53
55
} ) ;
56
+ vectorLayer . setZIndex ( 1 ) ;
54
57
55
58
this . map = new Map ( {
56
59
target : 'map' ,
@@ -67,15 +70,9 @@ export class MapComponent implements OnInit {
67
70
maxZoom : 25
68
71
} )
69
72
} ) ;
70
- this . userLocationFeature . setStyle ( new Style ( {
71
- image : new Icon ( {
72
- src : '/pin/my_location.png' , // Pfad zu deinem benutzerdefinierten Pin-Bild
73
- anchor : [ 0.5 , 1 ] , // Bildausrichtung
74
- scale : 0.05 // Größe des Pins
75
- } )
76
- } ) ) ;
77
-
78
- this . vectorSource . addFeature ( this . userLocationFeature ) ;
73
+
74
+ this . addUserLocationPinLayer ( ) ;
75
+
79
76
this . map . on ( 'click' , this . handleMapClick . bind ( this ) ) ;
80
77
this . map . on ( 'pointermove' , this . handlePointerMove . bind ( this ) ) ;
81
78
@@ -108,7 +105,25 @@ export class MapComponent implements OnInit {
108
105
} )
109
106
} ) ) ;
110
107
} ) ;
108
+ this . isLoading = false ;
109
+ } ) ;
110
+ }
111
+
112
+ private addUserLocationPinLayer ( ) {
113
+ this . userLocationFeature . setStyle ( new Style ( {
114
+ image : new Icon ( {
115
+ src : '/pin/my_location.png' , // Pfad zu deinem benutzerdefinierten Pin-Bild
116
+ anchor : [ 0.5 , 1 ] , // Bildausrichtung
117
+ scale : 0.09 // Größe des Pins
118
+ } )
119
+ } ) ) ;
120
+ const userLocationVectorSource = new VectorSource ( ) ;
121
+ userLocationVectorSource . addFeature ( this . userLocationFeature ) ;
122
+ const userLocationVectorLayer = new VectorLayer ( {
123
+ source : userLocationVectorSource
111
124
} ) ;
125
+ userLocationVectorLayer . setZIndex ( 2 ) ;
126
+ this . map . addLayer ( userLocationVectorLayer ) ;
112
127
}
113
128
114
129
// eslint-disable-next-line @typescript-eslint/no-explicit-any
0 commit comments