mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-29 12:46:58 +02:00
MESSENGER-5379 dynamic location attribution from style.json
This commit is contained in:
@@ -68,6 +68,9 @@ struct LocationSharingMapView: UIViewRepresentable {
|
||||
|
||||
/// Called when the user pan on the map
|
||||
var userDidPan: (() -> Void)?
|
||||
|
||||
// bwi #5379: for copyright attribution
|
||||
var attributionsChanged: ((LocationSharingAttribution) -> Void)?
|
||||
|
||||
// MARK: - UIViewRepresentable
|
||||
|
||||
@@ -154,6 +157,23 @@ extension LocationSharingMapView {
|
||||
return nil
|
||||
}
|
||||
|
||||
func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
|
||||
// bwi #5379: set copyright to info from style json if available. Needs reevaluation if there is more than one source
|
||||
|
||||
var attribution = LocationSharingAttribution()
|
||||
|
||||
for source in style.sources {
|
||||
if let tileSource = source as? MGLRasterTileSource {
|
||||
for attributionInfo in tileSource.attributionInfos {
|
||||
attribution.copyrightTexts.append(attributionInfo.title.plainTextString())
|
||||
attribution.copyrightLinks.append(attributionInfo.url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
locationSharingMapView.attributionsChanged?(attribution)
|
||||
}
|
||||
|
||||
func mapViewDidFailLoadingMap(_ mapView: MGLMapView, withError error: Error) {
|
||||
locationSharingMapView.errorSubject.send(.failedLoadingMap)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user