mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Don't zoom too far if there is only one node with a position
This commit is contained in:
parent
0ad308c34d
commit
a8a0df5875
1 changed files with 8 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue