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

Commit

Permalink
icon debug app
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Apr 2, 2019
1 parent 097d96d commit ed923d5
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
40 changes: 40 additions & 0 deletions icon_debug_style/icon_debug/style.json
Original file line number Diff line number Diff line change
@@ -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"
}
}]
}
24 changes: 24 additions & 0 deletions platform/glfw/glfw_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions platform/glfw/glfw_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class GLFWView : public mbgl::RendererBackend, public mbgl::MapObserver {

// 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
Expand Down Expand Up @@ -90,6 +91,9 @@ class GLFWView : public mbgl::RendererBackend, public mbgl::MapObserver {
mbgl::AnnotationIDs animatedAnnotationIDs;
std::vector<double> animatedAnnotationAddedTimes;

void addMissingIcon();
void updateIcon();

private:
void toggle3DExtrusions(bool visible);

Expand Down

0 comments on commit ed923d5

Please sign in to comment.