kopia lustrzana https://github.com/f4exb/sdrangel
Center ADS-B map on My Location when map is first opened
rodzic
9eac758088
commit
84639d8716
|
@ -2391,17 +2391,29 @@ void ADSBDemodGUI::on_displaySettings_clicked()
|
||||||
|
|
||||||
void ADSBDemodGUI::applyMapSettings()
|
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();
|
QQuickItem *item = ui->map->rootObject();
|
||||||
|
|
||||||
// Save existing position of map
|
|
||||||
QObject *object = item->findChild<QObject*>("map");
|
QObject *object = item->findChild<QObject*>("map");
|
||||||
QGeoCoordinate coords;
|
QGeoCoordinate coords;
|
||||||
double zoom;
|
double zoom;
|
||||||
if (object != nullptr)
|
if (object != nullptr)
|
||||||
{
|
{
|
||||||
|
// Save existing position of map
|
||||||
coords = object->property("center").value<QGeoCoordinate>();
|
coords = object->property("center").value<QGeoCoordinate>();
|
||||||
zoom = object->property("zoomLevel").value<double>();
|
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
|
// Create the map using the specified provider
|
||||||
QQmlProperty::write(item, "mapProvider", "osm");
|
QQmlProperty::write(item, "mapProvider", "osm");
|
||||||
|
@ -2463,9 +2475,6 @@ void ADSBDemodGUI::applyMapSettings()
|
||||||
QObject *stationObject = newMap->findChild<QObject*>("station");
|
QObject *stationObject = newMap->findChild<QObject*>("station");
|
||||||
if(stationObject != NULL)
|
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>();
|
QGeoCoordinate coords = stationObject->property("coordinate").value<QGeoCoordinate>();
|
||||||
coords.setLatitude(stationLatitude);
|
coords.setLatitude(stationLatitude);
|
||||||
coords.setLongitude(stationLongitude);
|
coords.setLongitude(stationLongitude);
|
||||||
|
@ -2608,16 +2617,6 @@ ADSBDemodGUI::ADSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
|
||||||
Real stationAltitude = MainCore::instance()->getSettings().getAltitude();
|
Real stationAltitude = MainCore::instance()->getSettings().getAltitude();
|
||||||
m_azEl.setLocation(stationLatitude, stationLongitude, stationAltitude);
|
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
|
// Add airports within range of My Position
|
||||||
if (m_airportInfo != nullptr) {
|
if (m_airportInfo != nullptr) {
|
||||||
updateAirports();
|
updateAirports();
|
||||||
|
|
Ładowanie…
Reference in New Issue