summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnsis Brammanis <ansis@mapbox.com>2019-04-02 09:04:21 -0400
committerAnsis Brammanis <ansis@mapbox.com>2019-04-02 09:04:21 -0400
commited923d5331e103dd46858fb998e2da76f6172776 (patch)
tree3e5f6b20822267dcc874ca1832e294a46c8f3fe1
parent097d96de61f7edaddce475c5a9b1f21e960a1396 (diff)
downloadqtlocation-mapboxgl-ed923d5331e103dd46858fb998e2da76f6172776.tar.gz
-rw-r--r--icon_debug_style/icon_debug/style.json40
-rw-r--r--platform/glfw/glfw_view.cpp24
-rw-r--r--platform/glfw/glfw_view.hpp4
3 files changed, 68 insertions, 0 deletions
diff --git a/icon_debug_style/icon_debug/style.json b/icon_debug_style/icon_debug/style.json
new file mode 100644
index 0000000000..5da4125990
--- /dev/null
+++ b/icon_debug_style/icon_debug/style.json
@@ -0,0 +1,40 @@
+{
+ "version": 8,
+ "name": "Mapbox Streets",
+ "sprite": "mapbox://sprites/mapbox/streets-v8",
+ "glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
+ "sources": {
+ "point": {
+ "type": "geojson",
+ "data": {
+ "type": "Feature",
+ "properties": {},
+ "geometry": {
+ "type": "Point",
+ "coordinates": [0, 0]
+ }
+ }
+ }
+ },
+ "layers": [{
+ "id": "bg",
+ "type": "background",
+ "paint": {
+ "background-color": "#f00"
+ }
+ }, {
+ "id": "point",
+ "type": "circle",
+ "source": "point",
+ "paint": {
+ "circle-radius": 100
+ }
+ }, {
+ "id": "icon",
+ "type": "symbol",
+ "source": "point",
+ "layout": {
+ "icon-image": "missing-icon"
+ }
+ }]
+}
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp
index e768851a53..927ae92e88 100644
--- a/platform/glfw/glfw_view.cpp
+++ b/platform/glfw/glfw_view.cpp
@@ -176,6 +176,12 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action,
view->animateRouteCallback = nullptr;
switch (key) {
+ case GLFW_KEY_I:
+ view->addMissingIcon();
+ break;
+ case GLFW_KEY_G:
+ view->updateIcon();
+ break;
case GLFW_KEY_ESCAPE:
glfwSetWindowShouldClose(window, true);
break;
@@ -663,6 +669,24 @@ void GLFWView::onDidFinishLoadingStyle() {
}
}
+void GLFWView::addMissingIcon() {
+ map->getStyle().loadURL("http://localhost:8000/style.json");
+ map->jumpTo(mbgl::CameraOptions().withCenter(mbgl::LatLng {}).withZoom(0.0).withBearing(0.0).withPitch(0.0));
+}
+
+void GLFWView::updateIcon() {
+ map->getStyle().addImage(makeImage("missing-icon", 22, 22, 1));
+}
+
+void GLFWView::onStyleImageMissing(const std::string& id) {
+ fprintf(stderr, "MISSING %s\n", id.c_str());
+ if (false) {
+ }
+ //callback({});
+ //callback(makeImage(id, 22, 22, 1));
+ map->getStyle().addImage(makeImage(id, 22, 22, 1));
+}
+
void GLFWView::toggle3DExtrusions(bool visible) {
using namespace mbgl::style;
using namespace mbgl::style::expression::dsl;
diff --git a/platform/glfw/glfw_view.hpp b/platform/glfw/glfw_view.hpp
index d5acf697f7..44a832e3f5 100644
--- a/platform/glfw/glfw_view.hpp
+++ b/platform/glfw/glfw_view.hpp
@@ -49,6 +49,7 @@ public:
// mbgl::MapObserver implementation
void onDidFinishLoadingStyle() override;
+ void onStyleImageMissing(const std::string&) override;//, std::function<void(mbgl::optional<std::unique_ptr<mbgl::style::Image>>)>) override;
protected:
// mbgl::Backend implementation
@@ -90,6 +91,9 @@ private:
mbgl::AnnotationIDs animatedAnnotationIDs;
std::vector<double> animatedAnnotationAddedTimes;
+ void addMissingIcon();
+ void updateIcon();
+
private:
void toggle3DExtrusions(bool visible);