summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-07-07 19:07:35 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2016-07-11 17:01:32 +0300
commit462137a5360dc1d47a1cee654e43243e729befb7 (patch)
tree1a318d8dd0abbb49299adcc2868f302b1d98e943
parent5ad22bd672c84328c1274f7413959642d2a92576 (diff)
downloadqtlocation-mapboxgl-1.3v81.tar.gz
[Qt] Bind 'L' on the example app to runtime style example1.3v81
-rw-r--r--platform/qt/app/mapwindow.cpp29
-rw-r--r--platform/qt/app/qmapboxgl.gypi3
-rw-r--r--platform/qt/app/source.geojson253
-rw-r--r--platform/qt/app/source.qrc5
4 files changed, 290 insertions, 0 deletions
diff --git a/platform/qt/app/mapwindow.cpp b/platform/qt/app/mapwindow.cpp
index da8a9767ce..bc83e2d972 100644
--- a/platform/qt/app/mapwindow.cpp
+++ b/platform/qt/app/mapwindow.cpp
@@ -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;
diff --git a/platform/qt/app/qmapboxgl.gypi b/platform/qt/app/qmapboxgl.gypi
index 62a2939ad2..22b4e1281e 100644
--- a/platform/qt/app/qmapboxgl.gypi
+++ b/platform/qt/app/qmapboxgl.gypi
@@ -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)',
diff --git a/platform/qt/app/source.geojson b/platform/qt/app/source.geojson
new file mode 100644
index 0000000000..f639c1913e
--- /dev/null
+++ b/platform/qt/app/source.geojson
@@ -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
+ ]
+ ]
+ ]
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/platform/qt/app/source.qrc b/platform/qt/app/source.qrc
new file mode 100644
index 0000000000..60282b7178
--- /dev/null
+++ b/platform/qt/app/source.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>source.geojson</file>
+ </qresource>
+</RCC>