Add Zoom property to Live map chart (#4619)

It can be customized in config window, defaults to currently hardcoded value.
This commit is contained in:
Peret
2025-02-18 20:13:33 +01:00
committed by GitHub
parent 51e608e1c9
commit 1baa3db27e
2 changed files with 16 additions and 3 deletions

View File

@@ -82,11 +82,19 @@ LiveMapWebPageWindow::LiveMapWebPageWindow(Context *context) : GcChartWindow(con
customUrl = new QLineEdit(this);
customUrl->setFixedWidth(600);
customZoomLabel = new QLabel(tr("Initial Zoom"));
customZoom = new QSpinBox(this);
customZoom->setFixedWidth(60);
customZoom->setRange(0, 20); // Set the range for zoom levels
if (customUrl->text().trimmed().isEmpty()) customUrl->setText("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png");
commonLayout->addRow(customUrlLabel, customUrl);
connect(customUrl, SIGNAL(returnPressed()), this, SLOT(userUrl()));
if (customZoom->text().trimmed().isEmpty()) customZoom->setValue(15);
commonLayout->addRow(customZoomLabel, customZoom);
applyButton = new QPushButton(application->style()->standardIcon(QStyle::SP_ArrowRight), tr("Apply changes"), this);
commonLayout->addRow(applyButton);
@@ -145,7 +153,8 @@ void LiveMapWebPageWindow::ergFileSelected(ErgFile* f)
}
else
{
QString js = ("<div><script type=\"text/javascript\">initMap (" + startingLat + ", " + startingLon + ",13);</script></div>\n");
QString sZoom = QString::number(zoom());
QString js = ("<div><script type=\"text/javascript\">initMap (" + startingLat + ", " + startingLon + ", " + sZoom + ");</script></div>\n");
routeLatLngs = "[";
QString code = "";
@@ -230,7 +239,8 @@ void LiveMapWebPageWindow::telemetryUpdate(RealtimeData rtd)
code = "";
if (!markerIsVisible)
{
code = QString("centerMap (" + sLat + ", " + sLon + ", " + "15" + ");");
QString sZoom = QString::number(zoom());
code += QString("centerMap (" + sLat + ", " + sLon + ", " + sZoom + ");");
code += QString("showMyMarker (" + sLat + ", " + sLon + ");");
markerIsVisible = true;
}

View File

@@ -59,6 +59,7 @@ class LiveMapWebPageWindow : public GcChartWindow
// properties can be saved/restored/set by the layout manager
Q_PROPERTY(QString url READ url WRITE setUrl USER true)
Q_PROPERTY(int zoom READ zoom WRITE setZoom USER true)
public:
LiveMapWebPageWindow(Context *);
@@ -72,6 +73,8 @@ class LiveMapWebPageWindow : public GcChartWindow
// set/get properties
QString url() const { return customUrl->text(); }
void setUrl(QString x) { customUrl->setText(x); }
int zoom() const { return customZoom->value(); }
void setZoom(int x) { customZoom->setValue(x); }
public slots:
void configChanged(qint32);
@@ -96,7 +99,7 @@ class LiveMapWebPageWindow : public GcChartWindow
QLineEdit* rCustomUrl;
QLineEdit* customLat;
QLineEdit* customLon;
QLineEdit* customZoom;
QSpinBox* customZoom;
QPushButton* rButton;
QPushButton* applyButton;