@@ -49,6 +49,8 @@ struct MapView: View {
4949 @State private var navigateToProfile = false
5050
5151 @State private var showManageQuestSheet = false
52+
53+ @State private var showZoomInAlert = false
5254
5355 var body : some View {
5456 NavigationStack {
@@ -145,6 +147,11 @@ struct MapView: View {
145147 . animation ( . easeInOut, value: viewModel. selectedAnnotaions. count)
146148 }
147149 }
150+ . alert ( " Zoom in to download data " , isPresented: $showZoomInAlert) {
151+ Button ( " OK " , role: . cancel) { }
152+ } message: {
153+ Text ( " The map area is too large. Please zoom in and try again. " )
154+ }
148155 }
149156 . environmentObject ( contextualInfo)
150157 . navigationBarHidden ( isPresented)
@@ -222,6 +229,13 @@ struct MapView: View {
222229
223230 case . downloadData:
224231 print ( " Download data here " )
232+
233+ guard let mapView = mapViewRef else { return }
234+ let bbox = viewModel. boundingBoxFromVisibleMapRect ( mapView: mapView)
235+ if !isBBoxValid( bbox) {
236+ showZoomInAlert = true
237+ return
238+ }
225239 guard let mapView = mapViewRef else { return }
226240 viewModel. fetchOSMDataFor ( from: . visibleRect( mapView: mapView) )
227241
@@ -370,6 +384,12 @@ struct MapView: View {
370384 contextualInfo. info = contextualinfo
371385
372386 }
387+
388+ func isBBoxValid( _ bbox: BBox ) -> Bool {
389+ let latDelta = bbox. maxLat - bbox. minLat
390+ let lonDelta = bbox. maxLon - bbox. minLon
391+ return latDelta * lonDelta <= 1.0
392+ }
373393}
374394
375395
0 commit comments