diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-11-16 00:49:51 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-11-16 00:49:51 +0200 |
commit | d4ece6eb0b191120c3e4e08ae39cc6b3c252210a (patch) | |
tree | 769e3f9c3c071b9d58df196a3653124b21381d7c | |
parent | 73dcfe2d0d3475ad9584969c7908ba681a3f5bfa (diff) | |
download | qtlocation-mapboxgl-upstream/expression-glfw-demo-test.tar.gz |
expression-glfw-demo-testupstream/expression-glfw-demo-test
-rw-r--r-- | platform/glfw/glfw_view.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 9179113139..d2443b32a5 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -8,6 +8,12 @@ #include <mbgl/style/transition_options.hpp> #include <mbgl/style/layers/fill_extrusion_layer.hpp> #include <mbgl/style/expression/dsl.hpp> +#include <mbgl/style/sources/geojson_source.hpp> +#include <mbgl/style/layers/symbol_layer.hpp> +#include <mbgl/style/expression/dsl.hpp> +#include <mbgl/style/expression/format_expression.hpp> +#include <mbgl/style/expression/formatted.hpp> +#include <mbgl/style/conversion/function.hpp> #include <mbgl/util/logging.hpp> #include <mbgl/util/platform.hpp> #include <mbgl/util/string.hpp> @@ -276,6 +282,30 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, }; view->animateRouteCallback(view->map); } break; + case GLFW_KEY_T: { + auto source = std::make_unique<mbgl::style::GeoJSONSource>("GeoJSONSource"); + source->setGeoJSON(mbgl::Geometry<double> { mbgl::Point<double>{ 0, 0 } }); + view->map->getStyle().addSource(std::move(source)); + + auto layer = std::make_unique<mbgl::style::SymbolLayer>("SymbolLayer", "GeoJSONSource"); + std::vector<mbgl::style::expression::FormatExpressionSection> sections; + /// XXX 1 + sections.emplace_back(mbgl::style::conversion::convertTokenStringToExpression(std::string("foo")), mbgl::nullopt, mbgl::nullopt); + /// XXX 2 + //sections.emplace_back(mbgl::style::expression::dsl::literal("foo"), mbgl::nullopt, mbgl::nullopt); + /// XXX 3 + //std::vector<std::unique_ptr<mbgl::style::expression::Expression>> expressions; + //expressions.emplace_back(mbgl::style::expression::dsl::literal("foo")); + //sections.emplace_back(mbgl::style::expression::dsl::concat(std::move(expressions)), mbgl::nullopt, mbgl::nullopt); + /// WORKS + //sections.emplace_back(mbgl::style::expression::dsl::get("foo"), mbgl::nullopt, mbgl::nullopt); + + std::unique_ptr<mbgl::style::expression::Expression> expression = std::make_unique<mbgl::style::expression::FormatExpression>(std::move(sections)); + mbgl::style::PropertyValue<mbgl::style::expression::Formatted> formatValue {std::move(expression)}; + layer->setTextField(std::move(formatValue)); + + view->map->getStyle().addLayer(std::move(layer)); + } break; case GLFW_KEY_E: view->toggle3DExtrusions(!view->show3DExtrusions); break; |