Skip to content

Commit f4201b1

Browse files
Merge pull request #103 from Sybit-Education/feature/current-location
Feature/current location
2 parents 597bdd6 + 39d9bf9 commit f4201b1

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

src/app/components/map/map.component.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,12 @@
77
<path d="M8.5.5a.5.5 0 0 0-1 0v.518A7 7 0 0 0 1.018 7.5H.5a.5.5 0 0 0 0 1h.518A7 7 0 0 0 7.5 14.982v.518a.5.5 0 0 0 1 0v-.518A7 7 0 0 0 14.982 8.5h.518a.5.5 0 0 0 0-1h-.518A7 7 0 0 0 8.5 1.018zm-6.48 7A6 6 0 0 1 7.5 2.02v.48a.5.5 0 0 0 1 0v-.48a6 6 0 0 1 5.48 5.48h-.48a.5.5 0 0 0 0 1h.48a6 6 0 0 1-5.48 5.48v-.48a.5.5 0 0 0-1 0v.48A6 6 0 0 1 2.02 8.5h.48a.5.5 0 0 0 0-1zM8 10a2 2 0 1 0 0-4 2 2 0 0 0 0 4"/>
88
</svg>
99
</span>
10-
</button>
10+
</button>
11+
@if (isLoading) {
12+
<div class="loading d-flex justify-content-center align-items-center" style="height: 80vh;">
13+
<div class="spinner-border" role="status">
14+
<span class="sr-only">Loading...</span>
15+
</div>
16+
</div>
17+
}
18+

src/app/components/map/map.component.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@
2121
display: none;
2222
}
2323

24+
.loading {
25+
position: absolute;
26+
z-index: 99;
27+
top: 50px;
28+
left: 0;
29+
width: 100%;
30+
opacity: 80%;
31+
}
32+
2433
@media (max-width: 768px) {
2534
.map {
2635
height: 80vh;

src/app/components/map/map.component.ts

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { Activity } from '../../types/activity.interface';
2222
styleUrls: ['./map.component.scss']
2323
})
2424
export class MapComponent implements OnInit {
25+
isLoading = true;
2526
map!: Map;
2627
vectorSource!: VectorSource;
2728

@@ -47,10 +48,12 @@ export class MapComponent implements OnInit {
4748
}
4849

4950
ngOnInit(): void {
51+
this.isLoading = true;
5052
this.vectorSource = new VectorSource();
5153
const vectorLayer = new VectorLayer({
5254
source: this.vectorSource
5355
});
56+
vectorLayer.setZIndex(1);
5457

5558
this.map = new Map({
5659
target: 'map',
@@ -67,15 +70,9 @@ export class MapComponent implements OnInit {
6770
maxZoom: 25
6871
})
6972
});
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+
7976
this.map.on('click', this.handleMapClick.bind(this));
8077
this.map.on('pointermove', this.handlePointerMove.bind(this));
8178

@@ -108,7 +105,25 @@ export class MapComponent implements OnInit {
108105
})
109106
}));
110107
});
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
111124
});
125+
userLocationVectorLayer.setZIndex(2);
126+
this.map.addLayer(userLocationVectorLayer);
112127
}
113128

114129
// eslint-disable-next-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)