mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 09:32:52 +02:00
Show own location in map views (#7375)
* show own location on static sharing * show own location on live sharing * add tests and changelog * check location authorisation, fix center to current user location button * it moves request to LocationManager in proper service * add static location viewer service
This commit is contained in:
@@ -75,7 +75,7 @@ struct LocationSharingMapView: UIViewRepresentable {
|
||||
mapView.vc_removeAllAnnotations()
|
||||
mapView.addAnnotations(annotations)
|
||||
|
||||
if let highlightedAnnotation = highlightedAnnotation {
|
||||
if let highlightedAnnotation = highlightedAnnotation, !showsUserLocation {
|
||||
mapView.setCenter(highlightedAnnotation.coordinate, zoomLevel: Constants.mapZoomLevel, animated: false)
|
||||
}
|
||||
|
||||
@@ -125,11 +125,14 @@ extension LocationSharingMapView {
|
||||
return LocationAnnotationView(userLocationAnnotation: userLocationAnnotation)
|
||||
} else if let pinLocationAnnotation = annotation as? PinLocationAnnotation {
|
||||
return LocationAnnotationView(pinLocationAnnotation: pinLocationAnnotation)
|
||||
} else if annotation is MGLUserLocation, let currentUserAvatarData = locationSharingMapView.userAvatarData {
|
||||
// Replace default current location annotation view with a UserLocationAnnotatonView when the map is center on user location
|
||||
return LocationAnnotationView(avatarData: currentUserAvatarData)
|
||||
} else if annotation is MGLUserLocation {
|
||||
if let currentUserAvatarData = locationSharingMapView.userAvatarData {
|
||||
// Replace default current location annotation view with a UserLocationAnnotatonView when the map is center on user location
|
||||
return LocationAnnotationView(avatarData: currentUserAvatarData)
|
||||
} else {
|
||||
return LocationAnnotationView(userPinLocationAnnotation: annotation)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,11 @@ class LocationAnnotationView: MGLUserLocationAnnotationView {
|
||||
|
||||
addUserMarkerView(with: userLocationAnnotation.avatarData)
|
||||
}
|
||||
|
||||
convenience init(userPinLocationAnnotation: MGLAnnotation) {
|
||||
self.init(annotation: userPinLocationAnnotation, reuseIdentifier: "userPinLocation")
|
||||
|
||||
addPinView()
|
||||
}
|
||||
convenience init(pinLocationAnnotation: PinLocationAnnotation) {
|
||||
// TODO: Use a reuseIdentifier
|
||||
self.init(annotation: pinLocationAnnotation, reuseIdentifier: nil)
|
||||
@@ -74,6 +78,16 @@ class LocationAnnotationView: MGLUserLocationAnnotationView {
|
||||
addMarkerView(avatarMarkerView)
|
||||
}
|
||||
|
||||
private func addPinView() {
|
||||
guard let pinView = UIHostingController(rootView: Image(uiImage: Asset.Images.locationMarkerIcon.image)
|
||||
.resizable()
|
||||
.foregroundColor(theme.colors.accent)).view else {
|
||||
return
|
||||
}
|
||||
|
||||
addMarkerView(pinView)
|
||||
}
|
||||
|
||||
private func addPinMarkerView() {
|
||||
guard let pinMarkerView = UIHostingController(rootView: LocationSharingMarkerView(backgroundColor: theme.colors.accent) {
|
||||
Image(uiImage: Asset.Images.locationPinIcon.image)
|
||||
|
||||
Reference in New Issue
Block a user