-
Notifications
You must be signed in to change notification settings - Fork 4
/
nyatrace_map.cpp
75 lines (66 loc) · 1.93 KB
/
nyatrace_map.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include "nyatrace_map.h"
#include "ui_nyatrace_map.h"
#include <QMetaObject>
#include <QQuickWidget>
NyaTraceMap::NyaTraceMap(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::NyaTraceMap)
{
ui->setupUi(this);
// 初始化追踪地图 (OSM)
ui->tracingMap->setSource(QUrl("qrc:/nyatrace_map.qml"));
ui->tracingMap->show();
}
NyaTraceMap::~NyaTraceMap()
{
delete ui;
}
void NyaTraceMap::DrawPoint(const double & latitude, const double & longitude, const unsigned short & accuracyRadius) {
// 根据纬度和经度在地图上画一个点和一个圆
QMetaObject::invokeMethod(
(QObject*)ui->tracingMap->rootObject(),
"drawHopPoint",
Qt::DirectConnection,
Q_ARG(QVariant, latitude),
Q_ARG(QVariant, longitude),
Q_ARG(QVariant, accuracyRadius)
);
}
void NyaTraceMap::ConnectLine(const double & latitude, const double & longitude) {
// 连一条线
QMetaObject::invokeMethod(
(QObject*)ui->tracingMap->rootObject(),
"connectLine",
Qt::DirectConnection,
Q_ARG(QVariant, latitude),
Q_ARG(QVariant, longitude)
);
}
void NyaTraceMap::SetTextAndGoto(const double & latitude, const double & longitude, QString & infoText) {
// 设置文字并跳转到
QMetaObject::invokeMethod(
(QObject*)ui->tracingMap->rootObject(),
"gotoCoordinate",
Qt::DirectConnection,
Q_ARG(QVariant, latitude),
Q_ARG(QVariant, longitude),
Q_ARG(QVariant, 14), // 缩放等级
Q_ARG(QVariant, infoText)
);
}
void NyaTraceMap::FitMap() {
// 自动调整地图
QMetaObject::invokeMethod(
(QObject*)ui->tracingMap->rootObject(),
"fitMap",
Qt::DirectConnection
);
}
void NyaTraceMap::ClearAll() {
// 清空所有数据
QMetaObject::invokeMethod(
(QObject*)ui->tracingMap->rootObject(),
"clearMap",
Qt::DirectConnection
);
}