File tree Expand file tree Collapse file tree 4 files changed +30
-10
lines changed Expand file tree Collapse file tree 4 files changed +30
-10
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,12 @@ cd build
87
87
qmake ..
88
88
```
89
89
90
+ ### Map API Key
91
+
92
+ Some map providers such as Mapbox require an API key. The map widget now
93
+ includes a **Map API key** field in its settings menu where you can paste
94
+ your key so those providers can load correctly.
95
+
90
96
## Contributing
91
97
92
98
**Thanks to all the people who have contributed !**
Original file line number Diff line number Diff line change @@ -338,6 +338,7 @@ Settings {
338
338
property bool show_gpio: false
339
339
property int selected_map_provider: 0
340
340
property int selected_map_variant: 0
341
+ property string map_api_key: " "
341
342
342
343
property bool show_vibration: false
343
344
Original file line number Diff line number Diff line change @@ -22,13 +22,11 @@ MapWidgetForm {
22
22
property variant map
23
23
24
24
Component .onCompleted : {
25
- // TODO: Figure out how we can get better (terrain) maps
26
- if (false ){
27
- pluginModel .append ({
28
- " name" : " mapboxgl" ,
29
- " description" : " MapboxGL"
30
- })
31
- }
25
+ // Add additional map providers
26
+ pluginModel .append ({
27
+ " name" : " mapboxgl" ,
28
+ " description" : " MapboxGL"
29
+ })
32
30
// Consti10: This way we need a restart of QOpenHD when the map is enabled, but we
33
31
// save some performance in case the map is not enabled
34
32
if (settings .show_map ){
@@ -64,13 +62,17 @@ MapWidgetForm {
64
62
function createMap (parent , provider ) {
65
63
console .log (" createMap(" + provider + " )" );
66
64
var plugin
65
+ var pluginParameters = " "
66
+ if (provider === " mapboxgl" ) {
67
+ pluginParameters = ' PluginParameter { name: "mapbox.access_token"; value: "' + settings .map_api_key + ' " }'
68
+ } else if (provider === " osm" ) {
69
+ pluginParameters = ' PluginParameter { name: "osm.mapping.custom.host"; value: "https://tile.openstreetmap.org/" }'
70
+ }
67
71
plugin = Qt .createQmlObject (`
68
72
import QtLocation 5.15
69
73
Plugin {
70
74
name: "` + provider + ` "
71
- PluginParameter {
72
- name: "osm.mapping.custom.host";
73
- value: "https://tile.openstreetmap.org/" }
75
+ ` + pluginParameters + `
74
76
}
75
77
` , mapWidget);
76
78
console .log (" Using plugin: " + plugin .name );
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ BaseWidget {
32
32
property alias widgetInnerMap: widgetInnerMap
33
33
property alias sidebar_wrapper: sidebar_wrapper
34
34
property alias pluginModel: pluginModel
35
+ property alias apiKeyField: apiKeyField
35
36
36
37
defaultAlignment: 1
37
38
defaultXOffset: 12
@@ -535,6 +536,16 @@ BaseWidget {
535
536
536
537
}
537
538
539
+ TextField {
540
+ id: apiKeyField
541
+ height: 48
542
+ width: parent .width
543
+ placeholderText: qsTr (" Map API key" )
544
+ text: settings .map_api_key
545
+ visible: pluginModel .get (providerDropdown .currentIndex ).name === " mapboxgl"
546
+ onEditingFinished: settings .map_api_key = text
547
+ }
548
+
538
549
ComboBox {
539
550
id: variantDropdown
540
551
height: 48
You can’t perform that action at this time.
0 commit comments