nav: draw destination pin on top of navigation path (#29050)

* Draw destination pin on top of navigation path

* fix draw ordering

fix draw ordering

* add todo

* rename to feature

* draft

* clean up

* testing

* testing 2

* Revert "testing 2"

This reverts commit fc236aafbc14bbdc5ddb52fb56265302247ddf4b.

* Revert "testing"

This reverts commit 982a508ad701268ebdae910980fd5464454f44a8.

* clean up

* add todo

* show!

* Update selfdrive/ui/qt/maps/map.cc

* lgtm

---------

Co-authored-by: Shane Smiskol <shane@smiskol.com>
old-commit-hash: ba03e9429044e40477c3b1f38737688f5a24f4b4
This commit is contained in:
Mitchell Goff
2023-07-20 00:54:42 -07:00
committed by GitHub
parent e56ac872e1
commit 949375984f
2 changed files with 28 additions and 8 deletions
+28 -7
View File
@@ -112,7 +112,25 @@ void MapWindow::initLayers() {
m_map->setPaintProperty("navLayer", "line-color-transition", transition);
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("pinLayer")) {
qDebug() << "Initializing pinLayer";
m_map->addImage("default_marker", QImage("../assets/navigation/default_marker.svg"));
QVariantMap pin;
pin["id"] = "pinLayer";
pin["type"] = "symbol";
pin["source"] = "pinSource";
m_map->addLayer(pin);
// FIXME: solve, workaround to remove animation on visibility property
QVariantMap transition;
transition["duration"] = 0; // ms
m_map->setPaintProperty("pinLayer", "icon-opacity-transition", transition);
m_map->setLayoutProperty("pinLayer", "icon-pitch-alignment", "viewport");
m_map->setLayoutProperty("pinLayer", "icon-image", "default_marker");
m_map->setLayoutProperty("pinLayer", "icon-ignore-placement", true);
m_map->setLayoutProperty("pinLayer", "icon-allow-overlap", true);
m_map->setLayoutProperty("pinLayer", "symbol-sort-key", 0);
}
if (!m_map->layerExists("carPosLayer")) {
qDebug() << "Initializing carPosLayer";
@@ -128,6 +146,7 @@ void MapWindow::initLayers() {
m_map->setLayoutProperty("carPosLayer", "icon-size", 0.5);
m_map->setLayoutProperty("carPosLayer", "icon-ignore-placement", true);
m_map->setLayoutProperty("carPosLayer", "icon-allow-overlap", true);
// TODO: remove, symbol-sort-key does not seem to matter outside of each layer
m_map->setLayoutProperty("carPosLayer", "symbol-sort-key", 0);
}
}
@@ -381,15 +400,17 @@ void MapWindow::offroadTransition(bool offroad) {
}
void MapWindow::updateDestinationMarker() {
if (marker_id != -1) {
m_map->removeAnnotation(marker_id);
marker_id = -1;
}
m_map->setPaintProperty("pinLayer", "icon-opacity", 0);
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));
auto point = coordinate_to_collection(*nav_dest);
QMapbox::Feature feature(QMapbox::Feature::PointType, point, {}, {});
QVariantMap pinSource;
pinSource["type"] = "geojson";
pinSource["data"] = QVariant::fromValue<QMapbox::Feature>(feature);
m_map->updateSource("pinSource", pinSource);
m_map->setPaintProperty("pinLayer", "icon-opacity", 1);
}
}
-1
View File
@@ -74,7 +74,6 @@ private:
QMapboxGLSettings m_settings;
QScopedPointer<QMapboxGL> m_map;
QMapbox::AnnotationID marker_id = -1;
void initLayers();