Skip to content
FlightMap.qml 3.47 KiB
Newer Older
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
dogmaphobic's avatar
dogmaphobic committed

import QtQuick          2.3
import QtQuick.Controls 1.2
import QtLocation       5.3
import QtPositioning    5.3
dogmaphobic's avatar
dogmaphobic committed

import QGroundControl                       1.0
dogmaphobic's avatar
dogmaphobic committed
import QGroundControl.FactSystem            1.0
import QGroundControl.Controls              1.0
import QGroundControl.FlightMap             1.0
import QGroundControl.ScreenTools           1.0
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.Vehicle               1.0
import QGroundControl.Mavlink               1.0
import QGroundControl.QGCPositionManager    1.0
dogmaphobic's avatar
dogmaphobic committed

dogmaphobic's avatar
dogmaphobic committed

    zoomLevel:                  QGroundControl.flightMapZoom
    center:                     QGroundControl.flightMapPosition
    gesture.flickDeceleration:  3000
    plugin:                     Plugin { name: "QGroundControl" }

    property string mapName:            'defaultMap'
    property bool   isSatelliteMap:     activeMapType.name.indexOf("Satellite") > -1 || activeMapType.name.indexOf("Hybrid") > -1
    property var    gcsPosition:        QtPositioning.coordinate()
dogmaphobic's avatar
dogmaphobic committed
    readonly property real  maxZoomLevel: 20

    function setVisibleRegion(region) {
        // This works around a bug on Qt where if you set a visibleRegion and then the user moves or zooms the map
        // and then you set the same visibleRegion the map will not move/scale appropriately since it thinks there
        // is nothing to do.
        _map.visibleRegion = QtPositioning.rectangle(QtPositioning.coordinate(0, 0), QtPositioning.coordinate(0, 0))
        _map.visibleRegion = region
    }

    ExclusiveGroup { id: mapTypeGroup }
    // Update ground station position
    Connections {
        target: QGroundControl.qgcPositionManger
        onLastPositionUpdated: {
            if (valid && lastPosition.latitude && Math.abs(lastPosition.latitude)  > 0.001 && lastPosition.longitude && Math.abs(lastPosition.longitude)  > 0.001) {
                gcsPosition = QtPositioning.coordinate(lastPosition.latitude,lastPosition.longitude)
            }
        }
    }
    function updateActiveMapType() {
        var settings =  QGroundControl.settingsManager.flightMapSettings
        var fullMapName = settings.mapProvider.enumStringValue + " " + settings.mapType.enumStringValue
Don Gagne's avatar
Don Gagne committed
        for (var i = 0; i < _map.supportedMapTypes.length; i++) {
            if (fullMapName === _map.supportedMapTypes[i].name) {
Don Gagne's avatar
Don Gagne committed
                _map.activeMapType = _map.supportedMapTypes[i]
    Component.onCompleted: updateActiveMapType()

    Connections {
        target:             QGroundControl.settingsManager.flightMapSettings.mapType
        onRawValueChanged:  updateActiveMapType()
    }

    Connections {
        target:             QGroundControl.settingsManager.flightMapSettings.mapProvider
        onRawValueChanged:  updateActiveMapType()
Don Gagne's avatar
Don Gagne committed
    /// Ground Station location
    MapQuickItem {
        anchorPoint.x:  sourceItem.anchorPointX
        anchorPoint.y:  sourceItem.anchorPointY
        visible:        gcsPosition.isValid
        coordinate:     gcsPosition
dogmaphobic's avatar
dogmaphobic committed
        sourceItem:     MissionItemIndexLabel {