[Qt] Bind 'L' on the example app to runtime style example
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
#include "mapwindow.hpp"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QColor>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QIcon>
|
||||
#include <QKeyEvent>
|
||||
#include <QMouseEvent>
|
||||
@@ -73,6 +75,33 @@ void MapWindow::keyPressEvent(QKeyEvent *ev)
|
||||
case Qt::Key_S:
|
||||
changeStyle();
|
||||
break;
|
||||
case Qt::Key_L: {
|
||||
m_map.setPaintProperty("water", "fill-color", QColor(255, 0, 0));
|
||||
m_map.setPaintProperty("building", "fill-color", "red");
|
||||
m_map.setPaintProperty("road-secondary-tertiary", "line-color", "red");
|
||||
|
||||
m_map.setLayoutProperty("road-label-small", "symbol-placement", "point");
|
||||
m_map.setLayoutProperty("road-label-medium", "symbol-placement", "point");
|
||||
m_map.setLayoutProperty("road-label-large", "symbol-placement", "point");
|
||||
|
||||
QFile geojson(":source.geojson");
|
||||
geojson.open(QIODevice::ReadOnly);
|
||||
|
||||
QVariantMap testSource;
|
||||
testSource["type"] = "geojson";
|
||||
testSource["data"] = geojson.readAll();
|
||||
|
||||
m_map.addSource("testSource", testSource);
|
||||
|
||||
QVariantMap testLayer;
|
||||
testLayer["id"] = "testLayer";
|
||||
testLayer["type"] = "fill";
|
||||
testLayer["source"] = "testSource";
|
||||
|
||||
m_map.addLayer(testLayer);
|
||||
m_map.setPaintProperty("testLayer", "fill-color", QColor("blue"));
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Tab:
|
||||
m_map.cycleDebugOptions();
|
||||
break;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
'main.cpp',
|
||||
'mapwindow.cpp',
|
||||
'mapwindow.hpp',
|
||||
'source.qrc',
|
||||
],
|
||||
|
||||
'include_dirs': [
|
||||
@@ -30,6 +31,8 @@
|
||||
'<@(qt_gui_cflags)',
|
||||
'<@(qt_opengl_cflags)',
|
||||
'-fPIC',
|
||||
# Qt4 generates code with unused variables.
|
||||
'-Wno-unused-variable',
|
||||
],
|
||||
'ldflags': [
|
||||
'<@(opengl_ldflags)',
|
||||
|
||||
253
platform/qt/app/source.geojson
Normal file
253
platform/qt/app/source.geojson
Normal file
@@ -0,0 +1,253 @@
|
||||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
69.2578125,
|
||||
-40.17887331434695
|
||||
],
|
||||
[
|
||||
69.2578125,
|
||||
-10.141931686131018
|
||||
],
|
||||
[
|
||||
110.74218749999999,
|
||||
-10.141931686131018
|
||||
],
|
||||
[
|
||||
110.74218749999999,
|
||||
-40.17887331434695
|
||||
],
|
||||
[
|
||||
69.2578125,
|
||||
-40.17887331434695
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
-71.71875,
|
||||
-33.43144133557529
|
||||
],
|
||||
[
|
||||
-71.71875,
|
||||
20.3034175184893
|
||||
],
|
||||
[
|
||||
-0.703125,
|
||||
20.3034175184893
|
||||
],
|
||||
[
|
||||
-0.703125,
|
||||
-33.43144133557529
|
||||
],
|
||||
[
|
||||
-71.71875,
|
||||
-33.43144133557529
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
97.3828125,
|
||||
38.548165423046584
|
||||
],
|
||||
[
|
||||
97.3828125,
|
||||
65.2198939361321
|
||||
],
|
||||
[
|
||||
155.0390625,
|
||||
65.2198939361321
|
||||
],
|
||||
[
|
||||
155.0390625,
|
||||
38.548165423046584
|
||||
],
|
||||
[
|
||||
97.3828125,
|
||||
38.548165423046584
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
24.93617534637451,
|
||||
60.17058143435276
|
||||
],
|
||||
[
|
||||
24.93617534637451,
|
||||
60.17149933938796
|
||||
],
|
||||
[
|
||||
24.93808507919311,
|
||||
60.17149933938796
|
||||
],
|
||||
[
|
||||
24.93808507919311,
|
||||
60.17058143435276
|
||||
],
|
||||
[
|
||||
24.93617534637451,
|
||||
60.17058143435276
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
24.94398593902588,
|
||||
60.170346617317186
|
||||
],
|
||||
[
|
||||
24.94398593902588,
|
||||
60.171456646699184
|
||||
],
|
||||
[
|
||||
24.947032928466797,
|
||||
60.171456646699184
|
||||
],
|
||||
[
|
||||
24.947032928466797,
|
||||
60.170346617317186
|
||||
],
|
||||
[
|
||||
24.94398593902588,
|
||||
60.170346617317186
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
24.938321113586426,
|
||||
60.16800902895082
|
||||
],
|
||||
[
|
||||
24.938321113586426,
|
||||
60.169204528711674
|
||||
],
|
||||
[
|
||||
24.941797256469727,
|
||||
60.169204528711674
|
||||
],
|
||||
[
|
||||
24.941797256469727,
|
||||
60.16800902895082
|
||||
],
|
||||
[
|
||||
24.938321113586426,
|
||||
60.16800902895082
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
24.939115047454834,
|
||||
60.17280143974311
|
||||
],
|
||||
[
|
||||
24.939115047454834,
|
||||
60.17387936902026
|
||||
],
|
||||
[
|
||||
24.94175434112549,
|
||||
60.17387936902026
|
||||
],
|
||||
[
|
||||
24.94175434112549,
|
||||
60.17280143974311
|
||||
],
|
||||
[
|
||||
24.939115047454834,
|
||||
60.17280143974311
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"type": "Polygon",
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
24.944372177124023,
|
||||
60.16034398818875
|
||||
],
|
||||
[
|
||||
24.944372177124023,
|
||||
60.16837195311943
|
||||
],
|
||||
[
|
||||
24.963769912719727,
|
||||
60.16837195311943
|
||||
],
|
||||
[
|
||||
24.963769912719727,
|
||||
60.16034398818875
|
||||
],
|
||||
[
|
||||
24.944372177124023,
|
||||
60.16034398818875
|
||||
]
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
5
platform/qt/app/source.qrc
Normal file
5
platform/qt/app/source.qrc
Normal file
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>source.geojson</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
Reference in New Issue
Block a user