From a8a0df5875ba62e84e975297a8fda4b8841e6553 Mon Sep 17 00:00:00 2001 From: Joshua Pirihi Date: Sun, 20 Feb 2022 19:20:36 +1300 Subject: [PATCH] Don't zoom too far if there is only one node with a position --- MeshtasticClient/Views/Map/MapViewModule.swift | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MeshtasticClient/Views/Map/MapViewModule.swift b/MeshtasticClient/Views/Map/MapViewModule.swift index 0bebbc20..19c4e0b9 100644 --- a/MeshtasticClient/Views/Map/MapViewModule.swift +++ b/MeshtasticClient/Views/Map/MapViewModule.swift @@ -285,6 +285,14 @@ public struct MapView: UIViewRepresentable { //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 + } else if minLat == maxLat && minLon == maxLon { + //then we are focussed on a single point (probably because there is only one node with a position) + //widen that out a little (don't zoom way in to that point) + + //0.001 degrees latitude is about 100m + //the mapView.regionThatFits call below will expand this out to a rectangle + minLat = minLat - 0.001 + maxLat = maxLat + 0.001 } let centerCoord = CLLocationCoordinate2D(latitude: (minLat+maxLat)/2, longitude: (minLon+maxLon)/2)