• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • examples
  • qml
  • position-tracking
position-tracking.qml
Go to the documentation of this file.
1 // This file is part of the Marble Virtual Globe.
2 //
3 // This program is free software licensed under the GNU LGPL. You can
4 // find a copy of this license in LICENSE.txt in the top directory of
5 // the source code.
6 //
7 // Copyright 2011 Dennis Nienhüser <earthwings@gentoo.org>
8 
9 // A (gps) tracking example. Shows the current (gps) position on the map
10 // using a small ghost image. The visibility of the track can be toggled.
11 
12 import Qt 4.7
13 import org.kde.edu.marble 0.11
14 
15 Rectangle {
16  id: screen
17  width: 640; height: 480
18 
19  // Delivers the current (gps) position
20  PositionSource {
21  id: gpsd
22 
23  // Can optionally be used to select a specific position provider
24  // plugin of marble. Per default the first one is used.
25  // The value is the nameId() of an installed Marble PositionProviderPlugin,
26  // e.g. Gpsd
27  //source: "Gpsd"
28 
29  // This starts/stops gps tracking
30  active: false
31 
32  // A small grow/shrink animation of the ghost to indicate position updates
33  onPositionChanged: {
34  growAnimation.running = true
35  if ( map.autoCenter ) {
36  map.center = gpsd.position
37  }
38  }
39  }
40 
41  // The map widget
42  MarbleWidget {
43  id: map
44  anchors.fill: parent
45 
46  property bool autoCenter: false
47 
48  mapThemeId: "earth/openstreetmap/openstreetmap.dgml"
49  activeFloatItems: [ "compass", "scalebar", "progress" ]
50 
51  // The grouped property tracking provides access to tracking related
52  // properties
53  property Tracking tracking: Tracking {
54  // We connect the position source from above with the map
55  positionSource: gpsd
56  map: map
57 
58  // Don't show the default Marble position indicator (arrow)
59  positionMarkerType: Tracking.Circle
60 
61  // Initially we don't show the track
62  showTrack: false
63 
64  // We have our own position marker, the image of a ghost.
65  // Marble will take care of positioning it correctly. It will
66  // be hidden when there is no current position or it is not
67  // visible on the screen
68  positionMarker: marker
69  }
70 
71  Row {
72  x: 10; y: 10
73  spacing: 10
74 
75  Toggle {
76  id: toggleGps
77  width: 140
78  text: gpsd.active ? "(" + Math.round( 100000 * gpsd.position.longitude ) / 100000 + ", " + Math.round( 100000 * gpsd.position.latitude ) / 100000 + ")" : "GPS off"
79  onToggled: gpsd.active = !gpsd.active
80  }
81 
82  Toggle {
83  id: toggleTrack
84  text: "Show Track"
85  onToggled: map.tracking.showTrack = !map.tracking.showTrack
86  }
87 
88  Toggle {
89  id: toggleCenter
90  text: "Auto Center"
91  onToggled: map.autoCenter = !map.autoCenter
92  }
93  }
94 
95  }
96 
97  // A small ghost indicates the current position
98  Image {
99  id: marker
100  width: 60
101  fillMode: Image.PreserveAspectFit
102  smooth: true
103  source: "ghost.svg"
104  visible: false
105 
106  PropertyAnimation on x { duration: 300; easing.type: Easing.OutBounce }
107  PropertyAnimation on y { duration: 300; easing.type: Easing.OutBounce }
108 
109  SequentialAnimation {
110  id: growAnimation
111  PropertyAnimation {
112  target: marker
113  properties: "scale"
114  to: 1.2
115  duration: 150
116  }
117  PropertyAnimation {
118  target: marker
119  properties: "scale"
120  to: 1.0
121  duration: 150
122  }
123  }
124  }
125 }
tracking
Definition: position-tracking.qml:12
Tracking
Definition: Tracking.qml:16
Toggle::active
bool active
Definition: Toggle.qml:14
Toggle
Definition: Toggle.qml:11
PositionSource
Definition: PositionSource.h:25
Tracking::Circle
Definition: Tracking.h:48
MarbleWidget
Wraps a Marble::MarbleWidget, providing access to important properties and methods.
Definition: MarbleDeclarativeWidget.h:50
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:41 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal