• 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
  • src
  • apps
  • marble-touch
PositionIndicator.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 // Copyright 2011 Daniel Marth <danielmarth@gmx.at>
9 // Copyright 2013 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
10 
11 import QtQuick 1.0
12 import org.kde.edu.marble 0.11
13 
14 Item {
15  property MarbleWidget map
16  property Tracking tracking
17 
18  Image {
19  id: positionFinderDirection
20  anchors.right: parent.right
21  anchors.bottom: parent.bottom
22  anchors.margins: 10
23  z: 10
24  visible: tracking !== null
25  smooth: true
26 
27  source: "qrc:/icons/marker-direction.svg"
28  //rotation: 180 + tracking.lastKnownPosition.bearing( map.center.longitude, map.center.latitude )
29  }
30 
31  Image {
32  id: positionFinder
33  anchors.right: parent.right
34  anchors.bottom: parent.bottom
35  anchors.margins: 10
36  z: 10
37  visible: tracking !== null
38 
39  source: ( tracking !== null && tracking.positionSource.hasPosition ) ? "qrc:/icons/marker.svg" : "qrc:/icons/marker-yellow.svg"
40 
41  MouseArea {
42  anchors.fill: parent
43  onClicked: centerOn( tracking.lastKnownPosition.longitude, tracking.lastKnownPosition.latitude )
44  }
45  }
46 
47  Rectangle {
48  anchors.bottom: positionFinder.top
49  width: positionDistanceText.width + 6
50  height: positionDistanceText.height + 4
51  anchors.right: parent.right
52  anchors.margins: 4
53  visible: tracking !== null
54  radius: 5
55  color: Qt.rgba(192/255, 192/255, 192/255, 192/255)
56 
57  Text {
58  id: positionDistanceText
59  anchors.centerIn: parent
60  }
61  }
62 
63  function updatePositionIndicator() {
64  if (visible && map !== null && tracking !== null) {
65  var pos = map.pixel( tracking.lastKnownPosition.longitude, tracking.lastKnownPosition.latitude )
66  positionFinderDirection.rotation = 270 + 180.0 / Math.PI * Math.atan2 ( positionFinderDirection.y - pos.y, positionFinderDirection.x - pos.x )
67  var indicatorPosition = map.coordinate( positionFinderDirection.x, positionFinderDirection.y )
68  positionDistanceText.text = (tracking.lastKnownPosition.distance( indicatorPosition.longitude, indicatorPosition.latitude ) / 1000).toFixed(1) + " km"
69  }
70  }
71 
72  onMapChanged: {
73  map.visibleLatLonAltBoxChanged.connect( updatePositionIndicator )
74  updatePositionIndicator()
75  }
76 
77  onTrackingChanged: {
78  tracking.lastKnownPositionChanged.connect( updatePositionIndicator )
79  updatePositionIndicator()
80  }
81 
82  onVisibleChanged: updatePositionIndicator()
83 }
tracking
Definition: position-tracking.qml:12
Tracking
Definition: Tracking.qml:16
Rectangle
Marble::radius
static qreal radius(qreal zoom)
Definition: thumbnailer.cpp:99
QtConcurrent::map
QFuture< void > map(Sequence &sequence, MapFunction function)
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