Unverified Commit 88601df0 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #8464 from DonLakeFlyer/MapFitFix

MapFitFunctions: Fix even more bugs
parents 3ccee69c 123c055d
...@@ -41,7 +41,7 @@ Item { ...@@ -41,7 +41,7 @@ Item {
/// Normalize longitude to range: 0 to 360, W to E /// Normalize longitude to range: 0 to 360, W to E
function normalizeLon(lon) { function normalizeLon(lon) {
return lon + 180.0 return lon + 180.0
} }
/// Fits the visible region of the map to inclues all of the specified coordinates. If no coordinates /// Fits the visible region of the map to inclues all of the specified coordinates. If no coordinates
...@@ -69,7 +69,7 @@ Item { ...@@ -69,7 +69,7 @@ Item {
continue continue
} }
lat = normalizeLat(lat) lat = normalizeLat(lat)
lon = normalizeLon(lat) lon = normalizeLon(lon)
north = Math.max(north, lat) north = Math.max(north, lat)
south = Math.min(south, lat) south = Math.min(south, lat)
east = Math.max(east, lon) east = Math.max(east, lon)
...@@ -77,8 +77,8 @@ Item { ...@@ -77,8 +77,8 @@ Item {
} }
// Expand the coordinate bounding rect to make room for the tools around the edge of the map // Expand the coordinate bounding rect to make room for the tools around the edge of the map
var latDegreesPerPixel = (north - south) / mapFitViewport.width var latDegreesPerPixel = (north - south) / mapFitViewport.height
var lonDegreesPerPixel = (east - west) / mapFitViewport.height var lonDegreesPerPixel = (east - west) / mapFitViewport.width
north = Math.min(north + (mapFitViewport.y * latDegreesPerPixel), 180) north = Math.min(north + (mapFitViewport.y * latDegreesPerPixel), 180)
south = Math.max(south - ((map.height - mapFitViewport.bottom) * latDegreesPerPixel), 0) south = Math.max(south - ((map.height - mapFitViewport.bottom) * latDegreesPerPixel), 0)
west = Math.max(west - (mapFitViewport.x * lonDegreesPerPixel), 0) west = Math.max(west - (mapFitViewport.x * lonDegreesPerPixel), 0)
...@@ -94,7 +94,6 @@ Item { ...@@ -94,7 +94,6 @@ Item {
var topLeftCoord = QtPositioning.coordinate(north - 90.0, west - 180.0) var topLeftCoord = QtPositioning.coordinate(north - 90.0, west - 180.0)
var bottomRightCoord = QtPositioning.coordinate(south - 90.0, east - 180.0) var bottomRightCoord = QtPositioning.coordinate(south - 90.0, east - 180.0)
map.setVisibleRegion(QtPositioning.rectangle(topLeftCoord, bottomRightCoord)) map.setVisibleRegion(QtPositioning.rectangle(topLeftCoord, bottomRightCoord))
} }
function addMissionItemCoordsForFit(coordList) { function addMissionItemCoordsForFit(coordList) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment