Skip to content
GitLab
Menu
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
80554e9a
Commit
80554e9a
authored
Jan 02, 2021
by
Volker Krause
Browse files
Add action to open a proper map on the indoor map page
parent
a99bface
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/app/IndoorMapPage.qml
View file @
80554e9a
...
...
@@ -105,6 +105,11 @@ Kirigami.Page {
icon.color
:
Solid
.
NetworkStatus
.
metered
!=
Solid
.
NetworkStatus
.
No
?
Kirigami
.
Theme
.
neutralTextColor
:
Kirigami
.
Theme
.
textColor
onTriggered
:
queryLiveLocationData
();
},
Kirigami.Action
{
separator
:
true
},
Kirigami.Action
{
text
:
i18n
(
"
Open Map
"
);
onTriggered
:
NavigationController
.
showOnMap
(
map
.
mapData
.
center
.
y
,
map
.
mapData
.
center
.
x
,
18
);
},
Kirigami.Action
{
id
:
lightStyleAction
text
:
"
Light Style
"
...
...
src/app/navigationcontroller.cpp
View file @
80554e9a
...
...
@@ -48,14 +48,17 @@ void NavigationController::showOnMap(const QVariant &place)
}
const
auto
geo
=
LocationUtil
::
geo
(
place
);
const
auto
addr
=
LocationUtil
::
address
(
place
);
if
(
geo
.
isValid
())
{
// zoom out further from airports, they are larger and you usually want to go further away from them
showOnMap
(
geo
.
latitude
(),
geo
.
longitude
(),
place
.
userType
()
==
qMetaTypeId
<
Airport
>
()
?
12
:
17
);
return
;
}
const
auto
addr
=
LocationUtil
::
address
(
place
);
if
(
!
addr
.
isEmpty
())
{
QUrl
url
;
#ifdef Q_OS_ANDROID
QUrl
url
;
url
.
setScheme
(
QStringLiteral
(
"geo"
));
if
(
geo
.
isValid
())
{
url
.
setPath
(
QString
::
number
(
geo
.
latitude
())
+
QLatin1Char
(
','
)
+
QString
::
number
(
geo
.
longitude
()));
}
else
if
(
!
addr
.
isEmpty
())
{
url
.
setScheme
(
QStringLiteral
(
"geo"
));
url
.
setPath
(
QStringLiteral
(
"0,0"
));
QUrlQuery
query
;
query
.
addQueryItem
(
QStringLiteral
(
"q"
),
addr
.
streetAddress
()
+
QLatin1String
(
", "
)
...
...
@@ -63,29 +66,7 @@ void NavigationController::showOnMap(const QVariant &place)
+
addr
.
addressLocality
()
+
QLatin1String
(
", "
)
+
addr
.
addressCountry
());
url
.
setQuery
(
query
);
}
else
{
return
;
}
startActivity
(
url
);
#else
if
(
geo
.
isValid
())
{
// zoom out further from airports, they are larger and you usually want to go further away from them
const
auto
zoom
=
place
.
userType
()
==
qMetaTypeId
<
Airport
>
()
?
12
:
17
;
QUrl
url
;
url
.
setScheme
(
QStringLiteral
(
"https"
));
url
.
setHost
(
QStringLiteral
(
"www.openstreetmap.org"
));
url
.
setPath
(
QStringLiteral
(
"/"
));
const
QString
fragment
=
QLatin1String
(
"map="
)
+
QString
::
number
(
zoom
)
+
QLatin1Char
(
'/'
)
+
QString
::
number
(
geo
.
latitude
())
+
QLatin1Char
(
'/'
)
+
QString
::
number
(
geo
.
longitude
());
url
.
setFragment
(
fragment
);
QDesktopServices
::
openUrl
(
url
);
return
;
}
if
(
!
addr
.
isEmpty
())
{
QUrl
url
;
url
.
setScheme
(
QStringLiteral
(
"https"
));
url
.
setHost
(
QStringLiteral
(
"www.openstreetmap.org"
));
url
.
setPath
(
QStringLiteral
(
"/search"
));
...
...
@@ -96,9 +77,33 @@ void NavigationController::showOnMap(const QVariant &place)
QUrlQuery
query
;
query
.
addQueryItem
(
QStringLiteral
(
"query"
),
queryString
);
url
.
setQuery
(
query
);
#endif
QDesktopServices
::
openUrl
(
url
);
}
}
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
);
}
QDesktopServices
::
openUrl
(
url
);
}
bool
NavigationController
::
canNavigateTo
(
const
QVariant
&
place
)
...
...
src/app/navigationcontroller.h
View file @
80554e9a
...
...
@@ -19,6 +19,7 @@ class NavigationController
Q_GADGET
public:
Q_INVOKABLE
void
showOnMap
(
const
QVariant
&
place
);
Q_INVOKABLE
void
showOnMap
(
float
latitude
,
float
longitude
,
int
zoom
);
Q_INVOKABLE
bool
canNavigateTo
(
const
QVariant
&
place
);
Q_INVOKABLE
void
navigateTo
(
const
QVariant
&
place
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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