Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[Qt] Bind 'L' on the example app to runtime style example
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpsantos committed Jul 11, 2016
1 parent 5ad22bd commit 462137a
Show file tree
Hide file tree
Showing 4 changed files with 290 additions and 0 deletions.
29 changes: 29 additions & 0 deletions platform/qt/app/mapwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "mapwindow.hpp"

#include <QApplication>
#include <QColor>
#include <QDebug>
#include <QFile>
#include <QIcon>
#include <QKeyEvent>
#include <QMouseEvent>
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions platform/qt/app/qmapboxgl.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'main.cpp',
'mapwindow.cpp',
'mapwindow.hpp',
'source.qrc',
],

'include_dirs': [
Expand All @@ -30,6 +31,8 @@
'<@(qt_gui_cflags)',
'<@(qt_opengl_cflags)',
'-fPIC',
# Qt4 generates code with unused variables.
'-Wno-unused-variable',
],
'ldflags': [
'<@(opengl_ldflags)',
Expand Down
253 changes: 253 additions & 0 deletions platform/qt/app/source.geojson
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions platform/qt/app/source.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>source.geojson</file>
</qresource>
</RCC>

0 comments on commit 462137a

Please sign in to comment.