Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Itinerary
Commits
d3f4c2ab
Commit
d3f4c2ab
authored
Feb 02, 2022
by
Volker Krause
Browse files
Use geo: URIs on all platforms for opening external maps
We have the necessary infrastructure on Linux meanwhile as well.
parent
fa450111
Pipeline
#132040
passed with stage
in 2 minutes and 35 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/app/navigationcontroller.cpp
View file @
d3f4c2ab
...
...
@@ -56,53 +56,18 @@ void NavigationController::showOnMap(const QVariant &place)
const
auto
addr
=
LocationUtil
::
address
(
place
);
if
(
!
addr
.
isEmpty
())
{
QUrl
url
;
#ifdef Q_OS_ANDROID
url
.
setScheme
(
QStringLiteral
(
"geo"
));
url
.
setPath
(
QStringLiteral
(
"0,0"
));
QUrlQuery
query
;
query
.
addQueryItem
(
QStringLiteral
(
"q"
),
addr
.
streetAddress
()
+
QLatin1String
(
", "
)
+
addr
.
postalCode
()
+
QLatin1Char
(
' '
)
+
addr
.
addressLocality
()
+
QLatin1String
(
", "
)
+
addr
.
addressCountry
());
url
.
setQuery
(
query
);
#else
url
.
setScheme
(
QStringLiteral
(
"https"
));
url
.
setHost
(
QStringLiteral
(
"www.openstreetmap.org"
));
url
.
setPath
(
QStringLiteral
(
"/search"
));
const
QString
queryString
=
addr
.
streetAddress
()
+
QLatin1String
(
", "
)
+
addr
.
postalCode
()
+
QLatin1Char
(
' '
)
+
addr
.
addressLocality
()
+
QLatin1String
(
", "
)
+
addr
.
addressCountry
();
QUrlQuery
query
;
query
.
addQueryItem
(
QStringLiteral
(
"query"
),
queryString
);
url
.
setQuery
(
query
);
#endif
QDesktopServices
::
openUrl
(
url
);
QDesktopServices
::
openUrl
(
LocationUtil
::
geoUri
(
place
));
}
}
void
NavigationController
::
showOnMap
(
float
latitude
,
float
longitude
,
int
zoom
)
{
#ifdef Q_OS_ANDROID
constexpr
const
auto
useGeoUrl
=
true
;
#else
constexpr
const
auto
useGeoUrl
=
false
;
#endif
QUrl
url
;
if
(
useGeoUrl
)
{
url
.
setScheme
(
QStringLiteral
(
"geo"
));
url
.
setPath
(
QString
::
number
(
latitude
)
+
QLatin1Char
(
','
)
+
QString
::
number
(
longitude
));
}
else
{
url
.
setScheme
(
QStringLiteral
(
"https"
));
url
.
setHost
(
QStringLiteral
(
"www.openstreetmap.org"
));
url
.
setPath
(
QStringLiteral
(
"/"
));
const
QString
fragment
=
QLatin1String
(
"map="
)
+
QString
::
number
(
zoom
)
+
QLatin1Char
(
'/'
)
+
QString
::
number
(
latitude
)
+
QLatin1Char
(
'/'
)
+
QString
::
number
(
longitude
);
url
.
setFragment
(
fragment
);
}
url
.
setScheme
(
QStringLiteral
(
"geo"
));
url
.
setPath
(
QString
::
number
(
latitude
)
+
QLatin1Char
(
','
)
+
QString
::
number
(
longitude
));
QUrlQuery
query
;
query
.
addQueryItem
(
QStringLiteral
(
"z"
),
QString
::
number
(
zoom
));
url
.
setQuery
(
query
);
QDesktopServices
::
openUrl
(
url
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment