Meego Wiki
Views

QML/Get GPS data

From MeeGo wiki
(Difference between revisions)
Jump to: navigation, search
Line 89: Line 89:
         }
         }
     }
     }
-
    Flow {
 
-
        //LeftToRight: true
 
-
        width: mainPage.width
 
-
        id: buttonarea
 
-
        anchors.top:  positiondata.bottom
 
-
        anchors.topMargin: 50
 
-
        anchors.left:  positiondata.left
 
-
        spacing: 50
 
         Row {
         Row {
             id: switchrow
             id: switchrow
             width: 300
             width: 300
             spacing: 10
             spacing: 10
-
             anchors.top:  parent.top
+
             anchors.top:  positiondata.bottom
-
             anchors.left:  parent.left
+
             anchors.left:  positiondata.left
 +
            anchors.topMargin: 50
         // Switch for power saving: toggle gps on/off
         // Switch for power saving: toggle gps on/off
         Text {
         Text {
Line 116: Line 109:
             anchors.leftMargin: 50
             anchors.leftMargin: 50
         }
         }
-
    }
 
-
    Button {
 
-
        id: savebutton
 
-
        text: "Save"
 
-
        width: 300
 
-
        visible: true
 
-
        //This button saves coordinates, not implemented (yet)
 
     }
     }
}
}

Revision as of 09:47, 6 November 2011

Code snippet that draws ui and shows GPS data and accuracy, also with GPS on/off switch if one wants to conserve power.

// Made by: Ossipena
import QtQuick 1.1
import com.meego 1.0
import Qt 4.7
import QtMobility.location 1.1

Page {
    id: mainPage
    tools: commonTools
    //init GPS etc
    PositionSource {
        id: positionSource
        updateInterval: 1000
        //active: false
        active: gpsswitch.checked
    }
    function printableMethod(method) {
        if (method == PositionSource.SatellitePositioningMethod)
            return "Satellite";
        else if (method == PositionSource.NoPositioningMethod)
            return "Not available";
        else if (method == PositionSouce.NonSatellitePositioningMethod)
            return "Non-satellite";
        else if (method == PositionSource.AllPositioningMethods)
            return "All/multiple"
        return "source error";
    }
    Grid {
        id: positiondata
        anchors.top: parent.top
        anchors.topMargin: 50
        anchors.left:  parent.left
        anchors.leftMargin: 10
        columns: 2
        spacing: 5
        //visible: false
        Text {
            id:latitudelabel
            font.pointSize: 32
            text: "Latitude:"
        }
        Text {
            id: latitudetext
            font.pointSize: 32
            text: positionSource.position.coordinate.latitude
        }
        Text {
            id:longitudelabel
            font.pointSize: 32
            text: "Longitude: "
        }
        Text {
            id: longitudetext
            font.pointSize: 32
            text: positionSource.position.coordinate.longitude
        }
        Text{
            id:accuracylabel1
            font.pointSize:  16
            text: "Horizontal accuracy:"
        }
        Text{
            id: horiz_accuracy
            font.pointSize: 16
            text: positionSource.position.horizontalAccuracy
        }
        Text {
            id:heightlabel
            font.pointSize: 32
            text: "Height: "
        }
        Text {
            id: heighttext
            font.pointSize: 32
            text: positionSource.position.coordinate.altitude
        }
        Text{
            id:accuracylabel2
            font.pointSize:  16
            text: "Altitude accuracy:"
        }
        Text{
            id: vert_accuracy
            font.pointSize: 16
            text: positionSource.position.verticalAccuracy
        }
    }
        Row {
            id: switchrow
            width: 300
            spacing: 10
            anchors.top:  positiondata.bottom
            anchors.left:  positiondata.left
            anchors.topMargin: 50
        // Switch for power saving: toggle gps on/off
        Text {
            id:switchtext
            anchors.left: parent.left
            font.pointSize: 32
            text: gpsswitch.checked ? "GPS ON" : "GPS OFF"
        }
        Switch {
            id: gpsswitch
            checked: false
            anchors.left: switchtext.right
            anchors.leftMargin: 50
         }
    }
}
}


Personal tools