/**************************************************************************** * * (c) 2009-2016 QGROUNDCONTROL PROJECT * * QGroundControl is licensed according to the terms in the file * COPYING.md in the root of the source code directory. * ****************************************************************************/ import QtQuick 2.3 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.2 import QtPositioning 5.3 import QGroundControl 1.0 import QGroundControl.ScreenTools 1.0 import QGroundControl.Controls 1.0 import QGroundControl.Palette 1.0 DropButton { id: dropButton dropDirection: dropRight buttonImage: "/qmlimages/MapCenter.svg" viewportMargins: ScreenTools.defaultFontPixelWidth / 2 lightBorders: map.isSatelliteMap property var map property rect mapFitViewport property bool usePlannedHomePosition ///< true: planned home position used for calculations, false: vehicle home position use for calculations property var geoFenceController property var missionController property var rallyPointController property bool showMission: true property bool showAllItems: true property bool showFollowVehicle: false property bool followVehicle: false property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle function fitHomePosition() { var homePosition = QtPositioning.coordinate() var activeVehicle = QGroundControl.multiVehicleManager.activeVehicle if (usePlannedHomePosition) { homePosition = missionController.visualItems.get(0).coordinate } else if (activeVehicle) { homePosition = activeVehicle.homePosition } return homePosition } /// Normalize latitude to range: 0 to 180, S to N function normalizeLat(lat) { return lat + 90.0 } /// Normalize longitude to range: 0 to 360, W to E function normalizeLon(lon) { return lon + 180.0 } /// Fits the visible region of the map to inclues all of the specified coordinates. If no coordinates /// are specified the map will center to fitHomePosition() function fitMapViewportToAllCoordinates(coordList) { if (coordList.length === 0) { map.center = fitHomePosition() return } // 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 (i = 0; i < geoFenceController.polygon.count(); i++) { coordList.push(geoFenceController.polygon.path[i]) } } } function fitMapViewportToFenceItems() { var coordList = [ ] addFenceItemCoordsForFit(coordList) fitMapViewportToAllCoordinates(coordList) } function addRallyItemCoordsForFit(coordList) { for (var i=0; i