From 12df4c5a5177af33decec18880c7295a31082d19 Mon Sep 17 00:00:00 2001 From: Joshua Pirihi Date: Wed, 29 Dec 2021 16:15:49 +1300 Subject: [PATCH] Check for a valid mesh region before jumping to it --- MeshtasticClient/Views/Map/MapView.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MeshtasticClient/Views/Map/MapView.swift b/MeshtasticClient/Views/Map/MapView.swift index 399cfa57..ddc5f896 100644 --- a/MeshtasticClient/Views/Map/MapView.swift +++ b/MeshtasticClient/Views/Map/MapView.swift @@ -69,6 +69,12 @@ struct MapView: UIViewRepresentable { maxLon = max(maxLon, annotation.coordinate.longitude) } } + + //check if the mesh region looks sensible before we move to it. Otherwise we won't move the map (leave it at the current location) + if maxLat < minLat || (maxLat-minLat) > 5 || maxLon < minLon || (maxLon-minLon) > 5 { + return + } + let centerCoord = CLLocationCoordinate2D(latitude: (minLat+maxLat)/2, longitude: (minLon+maxLon)/2) let span = MKCoordinateSpan(latitudeDelta: (maxLat-minLat)*1.5, longitudeDelta: (maxLon-minLon)*1.5)