Fixing initial map region
This commit is contained in:
parent
9fca82d2d9
commit
48c700fc13
@ -1661,7 +1661,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 165;
|
CURRENT_PROJECT_VERSION = 166;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
||||||
@ -1690,7 +1690,7 @@
|
|||||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||||
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
CODE_SIGN_ENTITLEMENTS = AutoCat/AutoCat.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 165;
|
CURRENT_PROJECT_VERSION = 166;
|
||||||
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
DEVELOPMENT_TEAM = 46DTTB8X4S;
|
||||||
INFOPLIST_FILE = AutoCat/Info.plist;
|
INFOPLIST_FILE = AutoCat/Info.plist;
|
||||||
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
INFOPLIST_KEY_CFBundleDisplayName = AutoCat;
|
||||||
|
|||||||
@ -75,6 +75,7 @@ final class MapViewModel: ACHudContainer {
|
|||||||
title = String.localizedStringWithFormat(NSLocalizedString("events found", comment: ""), events.count)
|
title = String.localizedStringWithFormat(NSLocalizedString("events found", comment: ""), events.count)
|
||||||
await clusterManager.add(markers)
|
await clusterManager.add(markers)
|
||||||
await reloadMarkers()
|
await reloadMarkers()
|
||||||
|
currentRegion = getRegion(for: markers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,4 +113,29 @@ final class MapViewModel: ACHudContainer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getRegion(for markers: [MapMarkerModel]) -> MKCoordinateRegion {
|
||||||
|
guard !markers.isEmpty else {
|
||||||
|
return .init()
|
||||||
|
}
|
||||||
|
|
||||||
|
let latitudes = markers.map(\.coordinate.latitude)
|
||||||
|
let longitudes = markers.map(\.coordinate.longitude)
|
||||||
|
|
||||||
|
let minLat = latitudes.min() ?? 0
|
||||||
|
let maxLat = latitudes.max() ?? 0
|
||||||
|
let minLong = longitudes.min() ?? 0
|
||||||
|
let maxLong = longitudes.max() ?? 0
|
||||||
|
|
||||||
|
return .init(
|
||||||
|
center: .init(
|
||||||
|
latitude: (maxLat - minLat)/2,
|
||||||
|
longitude: (maxLong - minLong)/2
|
||||||
|
),
|
||||||
|
span: .init(
|
||||||
|
latitudeDelta: (maxLat - minLat)*1.2,
|
||||||
|
longitudeDelta: (maxLong - minLong)*1.2
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user