Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
0030c00e
Unverified
Commit
0030c00e
authored
Sep 01, 2020
by
Don Gagne
Committed by
GitHub
Sep 01, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9018 from shatyuka/master
Add support for custom Mapbox style
parents
8c7e8cf6
92f97355
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
0 deletions
+70
-0
MapboxMapProvider.cpp
src/QtLocationPlugin/MapboxMapProvider.cpp
+6
-0
MapboxMapProvider.h
src/QtLocationPlugin/MapboxMapProvider.h
+9
-0
QGCMapUrlEngine.cpp
src/QtLocationPlugin/QGCMapUrlEngine.cpp
+1
-0
OfflineMap.qml
src/QtLocationPlugin/QMLControl/OfflineMap.qml
+36
-0
App.SettingsGroup.json
src/Settings/App.SettingsGroup.json
+14
-0
AppSettings.cc
src/Settings/AppSettings.cc
+2
-0
AppSettings.h
src/Settings/AppSettings.h
+2
-0
No files found.
src/QtLocationPlugin/MapboxMapProvider.cpp
View file @
0030c00e
...
...
@@ -4,6 +4,7 @@
#include "SettingsManager.h"
static
const
QString
MapBoxUrl
=
QStringLiteral
(
"https://api.mapbox.com/v4/%1/%2/%3/%4.jpg80?access_token=%5"
);
static
const
QString
MapBoxUrlCustom
=
QStringLiteral
(
"https://api.mapbox.com/styles/v1/%1/%2/tiles/256/%3/%4/%5?access_token=%6"
);
MapboxMapProvider
::
MapboxMapProvider
(
const
QString
&
mapName
,
const
quint32
averageSize
,
const
QGeoMapType
::
MapStyle
mapType
,
QObject
*
parent
)
:
MapProvider
(
QStringLiteral
(
"https://www.mapbox.com/"
),
QStringLiteral
(
"jpg"
),
averageSize
,
mapType
,
parent
)
...
...
@@ -15,6 +16,11 @@ QString MapboxMapProvider::_getURL(const int x, const int y, const int zoom, QNe
Q_UNUSED
(
networkManager
)
const
QString
mapBoxToken
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
mapboxToken
()
->
rawValue
().
toString
();
if
(
!
mapBoxToken
.
isEmpty
())
{
if
(
_mapboxName
==
QString
(
"mapbox.custom"
))
{
const
QString
mapBoxAccount
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
mapboxAccount
()
->
rawValue
().
toString
();
const
QString
mapBoxStyle
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
mapboxStyle
()
->
rawValue
().
toString
();
return
MapBoxUrlCustom
.
arg
(
mapBoxAccount
).
arg
(
mapBoxStyle
).
arg
(
zoom
).
arg
(
x
).
arg
(
y
).
arg
(
mapBoxToken
);
}
return
MapBoxUrl
.
arg
(
_mapboxName
).
arg
(
zoom
).
arg
(
x
).
arg
(
y
).
arg
(
mapBoxToken
);
}
return
QString
();
...
...
src/QtLocationPlugin/MapboxMapProvider.h
View file @
0030c00e
...
...
@@ -151,3 +151,12 @@ public:
:
MapboxMapProvider
(
QStringLiteral
(
"mapbox.high-contrast"
),
AVERAGE_TILE_SIZE
,
QGeoMapType
::
CustomMap
,
parent
)
{}
};
class
MapboxCustomMapProvider
:
public
MapboxMapProvider
{
Q_OBJECT
public:
MapboxCustomMapProvider
(
QObject
*
parent
=
nullptr
)
:
MapboxMapProvider
(
QStringLiteral
(
"mapbox.custom"
),
AVERAGE_TILE_SIZE
,
QGeoMapType
::
CustomMap
,
parent
)
{}
};
src/QtLocationPlugin/QGCMapUrlEngine.cpp
View file @
0030c00e
...
...
@@ -67,6 +67,7 @@ UrlFactory::UrlFactory() : _timeout(5 * 1000) {
_providersTable
[
"Mapbox Outdoors"
]
=
new
MapboxOutdoorsMapProvider
(
this
);
_providersTable
[
"Mapbox RunBikeHike"
]
=
new
MapboxRunBikeHikeMapProvider
(
this
);
_providersTable
[
"Mapbox HighContrast"
]
=
new
MapboxHighContrastMapProvider
(
this
);
_providersTable
[
"Mapbox Custom"
]
=
new
MapboxCustomMapProvider
(
this
);
//_providersTable["MapQuest Map"] = new MapQuestMapMapProvider(this);
//_providersTable["MapQuest Sat"] = new MapQuestSatMapProvider(this);
...
...
src/QtLocationPlugin/QMLControl/OfflineMap.qml
View file @
0030c00e
...
...
@@ -36,6 +36,8 @@ Item {
property
var
_settings
:
_settingsManager
?
_settingsManager
.
offlineMapsSettings
:
null
property
var
_fmSettings
:
_settingsManager
?
_settingsManager
.
flightMapSettings
:
null
property
Fact
_mapboxFact
:
_settingsManager
?
_settingsManager
.
appSettings
.
mapboxToken
:
null
property
Fact
_mapboxAccountFact
:
_settingsManager
?
_settingsManager
.
appSettings
.
mapboxAccount
:
null
property
Fact
_mapboxStyleFact
:
_settingsManager
?
_settingsManager
.
appSettings
.
mapboxStyle
:
null
property
Fact
_esriFact
:
_settingsManager
?
_settingsManager
.
appSettings
.
esriToken
:
null
property
string
mapType
:
_fmSettings
?
(
_fmSettings
.
mapProvider
.
value
+
"
"
+
_fmSettings
.
mapType
.
value
)
:
""
...
...
@@ -316,6 +318,40 @@ Item {
font.pointSize
:
_adjustableFontPointSize
}
Item
{
width
:
1
;
height
:
1
;
visible
:
_mapboxAccountFact
?
_mapboxAccountFact
.
visible
:
false
}
QGCLabel
{
text
:
qsTr
(
"
Mapbox User Name
"
);
visible
:
_mapboxAccountFact
?
_mapboxAccountFact
.
visible
:
false
}
FactTextField
{
fact
:
_mapboxAccountFact
visible
:
_mapboxAccountFact
?
_mapboxAccountFact
.
visible
:
false
maximumLength
:
256
width
:
ScreenTools
.
defaultFontPixelWidth
*
30
}
QGCLabel
{
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
wrapMode
:
Text
.
WordWrap
text
:
qsTr
(
"
To enable custom Mapbox styles, enter your account name.
"
)
visible
:
_mapboxAccountFact
?
_mapboxAccountFact
.
visible
:
false
font.pointSize
:
_adjustableFontPointSize
}
Item
{
width
:
1
;
height
:
1
;
visible
:
_mapboxStyleFact
?
_mapboxStyleFact
.
visible
:
false
}
QGCLabel
{
text
:
qsTr
(
"
Mapbox Style ID
"
);
visible
:
_mapboxStyleFact
?
_mapboxStyleFact
.
visible
:
false
}
FactTextField
{
fact
:
_mapboxStyleFact
visible
:
_mapboxStyleFact
?
_mapboxStyleFact
.
visible
:
false
maximumLength
:
256
width
:
ScreenTools
.
defaultFontPixelWidth
*
30
}
QGCLabel
{
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
wrapMode
:
Text
.
WordWrap
text
:
qsTr
(
"
To enable custom Mapbox styles, enter your style ID.
"
)
visible
:
_mapboxStyleFact
?
_mapboxStyleFact
.
visible
:
false
font.pointSize
:
_adjustableFontPointSize
}
Item
{
width
:
1
;
height
:
1
;
visible
:
_esriFact
?
_esriFact
.
visible
:
false
}
QGCLabel
{
text
:
qsTr
(
"
Esri Access Token
"
);
visible
:
_esriFact
?
_esriFact
.
visible
:
false
}
FactTextField
{
...
...
src/Settings/App.SettingsGroup.json
View file @
0030c00e
...
...
@@ -196,6 +196,20 @@
"type"
:
"string"
,
"default"
:
""
},
{
"name"
:
"mapboxAccount"
,
"shortDesc"
:
"Account name for Mapbox maps"
,
"longDesc"
:
"Your personal account name for Mapbox maps"
,
"type"
:
"string"
,
"default"
:
""
},
{
"name"
:
"mapboxStyle"
,
"shortDesc"
:
"Map style ID"
,
"longDesc"
:
"Map design style ID for Mapbox maps"
,
"type"
:
"string"
,
"default"
:
""
},
{
"name"
:
"esriToken"
,
"shortDesc"
:
"Access token to Esri maps"
,
...
...
src/Settings/AppSettings.cc
View file @
0030c00e
...
...
@@ -119,6 +119,8 @@ DECLARE_SETTINGSFACT(AppSettings, savePath)
DECLARE_SETTINGSFACT
(
AppSettings
,
useChecklist
)
DECLARE_SETTINGSFACT
(
AppSettings
,
enforceChecklist
)
DECLARE_SETTINGSFACT
(
AppSettings
,
mapboxToken
)
DECLARE_SETTINGSFACT
(
AppSettings
,
mapboxAccount
)
DECLARE_SETTINGSFACT
(
AppSettings
,
mapboxStyle
)
DECLARE_SETTINGSFACT
(
AppSettings
,
esriToken
)
DECLARE_SETTINGSFACT
(
AppSettings
,
defaultFirmwareType
)
DECLARE_SETTINGSFACT
(
AppSettings
,
gstDebugLevel
)
...
...
src/Settings/AppSettings.h
View file @
0030c00e
...
...
@@ -47,6 +47,8 @@ public:
DEFINE_SETTINGFACT
(
useChecklist
)
DEFINE_SETTINGFACT
(
enforceChecklist
)
DEFINE_SETTINGFACT
(
mapboxToken
)
DEFINE_SETTINGFACT
(
mapboxAccount
)
DEFINE_SETTINGFACT
(
mapboxStyle
)
DEFINE_SETTINGFACT
(
esriToken
)
DEFINE_SETTINGFACT
(
defaultFirmwareType
)
DEFINE_SETTINGFACT
(
gstDebugLevel
)
...
...
Write
Preview
Markdown
is supported
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