Warning, /education/marble/examples/qml/position-tracking/position-tracking.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2011 Dennis Nienhüser <nienhueser@kde.org> 0004 0005 // A (gps) tracking example. Shows the current (gps) position on the map 0006 // using a small ghost image. The visibility of the track can be toggled. 0007 0008 import Qt 4.7 0009 import org.kde.marble 0.20 0010 0011 Rectangle { 0012 id: screen 0013 width: 640; height: 480 0014 0015 // Delivers the current (gps) position 0016 PositionSource { 0017 id: gpsd 0018 0019 // Can optionally be used to select a specific position provider 0020 // plugin of marble. Per default the first one is used. 0021 // The value is the nameId() of an installed Marble PositionProviderPlugin, 0022 // e.g. Gpsd 0023 //source: "Gpsd" 0024 0025 // This starts/stops gps tracking 0026 active: false 0027 0028 // A small grow/shrink animation of the ghost to indicate position updates 0029 onPositionChanged: { 0030 growAnimation.running = true 0031 if ( map.autoCenter ) { 0032 map.center = gpsd.position 0033 } 0034 } 0035 } 0036 0037 // The map widget 0038 MarbleWidget { 0039 id: map 0040 anchors.fill: parent 0041 0042 property bool autoCenter: false 0043 0044 mapThemeId: "earth/openstreetmap/openstreetmap.dgml" 0045 activeFloatItems: [ "compass", "scalebar", "progress" ] 0046 0047 // The grouped property tracking provides access to tracking related 0048 // properties 0049 property Tracking tracking: Tracking { 0050 // We connect the position source from above with the map 0051 positionSource: gpsd 0052 map: map 0053 0054 // Don't show the default Marble position indicator (arrow) 0055 positionMarkerType: Tracking.Circle 0056 0057 // Initially we don't show the track 0058 showTrack: false 0059 0060 // We have our own position marker, the image of a ghost. 0061 // Marble will take care of positioning it correctly. It will 0062 // be hidden when there is no current position or it is not 0063 // visible on the screen 0064 positionMarker: marker 0065 } 0066 0067 Row { 0068 x: 10; y: 10 0069 spacing: 10 0070 0071 Toggle { 0072 id: toggleGps 0073 width: 140 0074 text: gpsd.active ? "(" + Math.round( 100000 * gpsd.position.longitude ) / 100000 + ", " + Math.round( 100000 * gpsd.position.latitude ) / 100000 + ")" : "GPS off" 0075 onToggled: gpsd.active = !gpsd.active 0076 } 0077 0078 Toggle { 0079 id: toggleTrack 0080 text: "Show Track" 0081 onToggled: map.tracking.showTrack = !map.tracking.showTrack 0082 } 0083 0084 Toggle { 0085 id: toggleCenter 0086 text: "Auto Center" 0087 onToggled: map.autoCenter = !map.autoCenter 0088 } 0089 } 0090 0091 } 0092 0093 // A small ghost indicates the current position 0094 Image { 0095 id: marker 0096 width: 60 0097 fillMode: Image.PreserveAspectFit 0098 smooth: true 0099 source: "ghost.svg" 0100 visible: false 0101 0102 PropertyAnimation on x { duration: 300; easing.type: Easing.OutBounce } 0103 PropertyAnimation on y { duration: 300; easing.type: Easing.OutBounce } 0104 0105 SequentialAnimation { 0106 id: growAnimation 0107 PropertyAnimation { 0108 target: marker 0109 properties: "scale" 0110 to: 1.2 0111 duration: 150 0112 } 0113 PropertyAnimation { 0114 target: marker 0115 properties: "scale" 0116 to: 1.0 0117 duration: 150 0118 } 0119 } 0120 } 0121 }