1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-27 18:28:54 -05:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Edouard Griffiths
17ef1601c8
Merge pull request #1048 from srcejon/adsb_map_updates
Center ADS-B map on My Location when map is first opened
2021-11-13 23:07:54 +01:00
Jon Beniston
84639d8716 Center ADS-B map on My Location when map is first opened 2021-11-13 18:17:37 +00:00

View File

@ -2391,17 +2391,29 @@ void ADSBDemodGUI::on_displaySettings_clicked()
void ADSBDemodGUI::applyMapSettings()
{
Real stationLatitude = MainCore::instance()->getSettings().getLatitude();
Real stationLongitude = MainCore::instance()->getSettings().getLongitude();
Real stationAltitude = MainCore::instance()->getSettings().getAltitude();
QQuickItem *item = ui->map->rootObject();
// Save existing position of map
QObject *object = item->findChild<QObject*>("map");
QGeoCoordinate coords;
double zoom;
if (object != nullptr)
{
// Save existing position of map
coords = object->property("center").value<QGeoCoordinate>();
zoom = object->property("zoomLevel").value<double>();
}
else
{
// Center on my location when map is first opened
coords.setLatitude(stationLatitude);
coords.setLongitude(stationLongitude);
coords.setAltitude(stationAltitude);
zoom = 10.0;
}
// Create the map using the specified provider
QQmlProperty::write(item, "mapProvider", "osm");
@ -2463,9 +2475,6 @@ void ADSBDemodGUI::applyMapSettings()
QObject *stationObject = newMap->findChild<QObject*>("station");
if(stationObject != NULL)
{
Real stationLatitude = MainCore::instance()->getSettings().getLatitude();
Real stationLongitude = MainCore::instance()->getSettings().getLongitude();
Real stationAltitude = MainCore::instance()->getSettings().getAltitude();
QGeoCoordinate coords = stationObject->property("coordinate").value<QGeoCoordinate>();
coords.setLatitude(stationLatitude);
coords.setLongitude(stationLongitude);
@ -2608,16 +2617,6 @@ ADSBDemodGUI::ADSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
Real stationAltitude = MainCore::instance()->getSettings().getAltitude();
m_azEl.setLocation(stationLatitude, stationLongitude, stationAltitude);
// Centre map at My Position
QQuickItem *item = ui->map->rootObject();
QObject *object = item->findChild<QObject*>("map");
if(object != NULL)
{
QGeoCoordinate coords = object->property("center").value<QGeoCoordinate>();
coords.setLatitude(stationLatitude);
coords.setLongitude(stationLongitude);
object->setProperty("center", QVariant::fromValue(coords));
}
// Add airports within range of My Position
if (m_airportInfo != nullptr) {
updateAirports();