mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-15 22:32:11 +08:00
Navigation: add destination marker (#26873)
* add navigation destination marker * fix removal * update default marker icon * update default marker Co-authored-by: Kurt Nistelberger <kurt.nistelberger@gmail.com> old-commit-hash: b6440304d59d13b918842f68ce9f3417e3e0ecbc
This commit is contained in:
committed by
GitHub
parent
baad7c8f38
commit
e142178284
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:44003b473b02603eb2929ab96c663577c8d020d50bed0803d5b2898baea8341f
|
||||
size 389
|
||||
@@ -47,7 +47,7 @@ MapWindow::MapWindow(const QMapboxGLSettings &settings) : m_settings(settings),
|
||||
map_eta->setVisible(false);
|
||||
|
||||
auto last_gps_position = coordinate_from_param("LastGPSPosition");
|
||||
if (last_gps_position) {
|
||||
if (last_gps_position.has_value()) {
|
||||
last_position = *last_gps_position;
|
||||
}
|
||||
|
||||
@@ -82,6 +82,7 @@ void MapWindow::initLayers() {
|
||||
m_map->setPaintProperty("navLayer", "line-color", QColor("#31a1ee"));
|
||||
m_map->setPaintProperty("navLayer", "line-width", 7.5);
|
||||
m_map->setLayoutProperty("navLayer", "line-cap", "round");
|
||||
m_map->addAnnotationIcon("default_marker", QImage("../assets/navigation/default_marker.svg"));
|
||||
}
|
||||
if (!m_map->layerExists("carPosLayer")) {
|
||||
qDebug() << "Initializing carPosLayer";
|
||||
@@ -220,7 +221,6 @@ void MapWindow::updateState(const UIState &s) {
|
||||
emit instructionsChanged(i);
|
||||
}
|
||||
} else {
|
||||
m_map->setPitch(MIN_PITCH);
|
||||
clearRoute();
|
||||
}
|
||||
}
|
||||
@@ -237,6 +237,7 @@ void MapWindow::updateState(const UIState &s) {
|
||||
m_map->setLayoutProperty("navLayer", "visibility", "visible");
|
||||
|
||||
route_rcv_frame = sm.rcv_frame("navRoute");
|
||||
update_destination_marker();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,6 +275,7 @@ void MapWindow::clearRoute() {
|
||||
if (!m_map.isNull()) {
|
||||
m_map->setLayoutProperty("navLayer", "visibility", "none");
|
||||
m_map->setPitch(MIN_PITCH);
|
||||
update_destination_marker();
|
||||
}
|
||||
|
||||
map_instructions->hideIfNoError();
|
||||
@@ -361,6 +363,19 @@ void MapWindow::offroadTransition(bool offroad) {
|
||||
last_bearing = {};
|
||||
}
|
||||
|
||||
void MapWindow::update_destination_marker() {
|
||||
if (marker_id != -1) {
|
||||
m_map->removeAnnotation(marker_id);
|
||||
marker_id = -1;
|
||||
}
|
||||
|
||||
auto nav_dest = coordinate_from_param("NavDestination");
|
||||
if (nav_dest.has_value()) {
|
||||
auto ano = QMapbox::SymbolAnnotation {*nav_dest, "default_marker"};
|
||||
marker_id = m_map->addAnnotation(QVariant::fromValue<QMapbox::SymbolAnnotation>(ano));
|
||||
}
|
||||
}
|
||||
|
||||
MapInstructions::MapInstructions(QWidget * parent) : QWidget(parent) {
|
||||
is_rhd = Params().getBool("IsRhdDetected");
|
||||
QHBoxLayout *main_layout = new QHBoxLayout(this);
|
||||
|
||||
@@ -79,6 +79,7 @@ private:
|
||||
|
||||
QMapboxGLSettings m_settings;
|
||||
QScopedPointer<QMapboxGL> m_map;
|
||||
QMapbox::AnnotationID marker_id = -1;
|
||||
|
||||
void initLayers();
|
||||
|
||||
@@ -111,6 +112,7 @@ private:
|
||||
MapETA* map_eta;
|
||||
|
||||
void clearRoute();
|
||||
void update_destination_marker();
|
||||
uint64_t route_rcv_frame = 0;
|
||||
|
||||
private slots:
|
||||
|
||||
Reference in New Issue
Block a user