diff --git a/src/MissionEditor/MissionEditor.qml b/src/MissionEditor/MissionEditor.qml index 95c1a560001633cf835b19a2330952ef3ee7434a..550cf2461a5698337c4ac3bc2208e9af3a585cc1 100644 --- a/src/MissionEditor/MissionEditor.qml +++ b/src/MissionEditor/MissionEditor.qml @@ -86,31 +86,114 @@ QGCView { return lon + 180.0 } - /// Fix the map viewport to the current mission items. - function fitViewportToMissionItems() { - if (_visualItems.count == 1) { + /// Fits the visible region of the map to inclues all of the specified coordinates. If no coordinates + /// are specified the map will fit to the home position + function fitMapViewportToAllCoordinates(coordList) { + if (coordList.length == 0) { editorMap.center = _visualItems.get(0).coordinate - } else { - var missionItem = _visualItems.get(0) - var north = normalizeLat(missionItem.coordinate.latitude) - var south = north - var east = normalizeLon(missionItem.coordinate.longitude) - var west = east - - for (var i=1; i<_visualItems.count; i++) { - missionItem = _visualItems.get(i) - - if (missionItem.specifiesCoordinate && !missionItem.isStandaloneCoordinate) { - var lat = normalizeLat(missionItem.coordinate.latitude) - var lon = normalizeLon(missionItem.coordinate.longitude) - - north = Math.max(north, lat) - south = Math.min(south, lat) - east = Math.max(east, lon) - west = Math.min(west, lon) - } + return + } + + // Determine the size of the inner portion of the map available for display + var toolbarHeight = qgcView.height - ScreenTools.availableHeight + var rightPanelWidth = _rightPanelWidth + var leftToolWidth = centerMapButton.x + centerMapButton.width + var availableWidth = qgcView.width - rightPanelWidth - leftToolWidth + var availableHeight = qgcView.height - toolbarHeight + + // Create the normalized lat/lon corners for the coordinate bounding rect from the list of coordinates + var north = normalizeLat(coordList[0].latitude) + var south = north + var east = normalizeLon(coordList[0].longitude) + var west = east + for (var i=1; i 2) { + for (var i=0; i