From 00e910c147e66e58e4e68fa3d02cf58d45c6502d Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Wed, 2 Apr 2014 15:01:05 -0700 Subject: [PATCH] bring back toggleRaster() by way of layer enable toggling --- include/llmr/map/map.hpp | 1 + include/llmr/map/source.hpp | 3 ++- ios/MBXViewController.mm | 2 +- src/map/map.cpp | 15 +++++++++++++-- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/include/llmr/map/map.hpp b/include/llmr/map/map.hpp index 22417bd34..a8cfdba5b 100644 --- a/include/llmr/map/map.hpp +++ b/include/llmr/map/map.hpp @@ -63,6 +63,7 @@ public: void stopRotating(); void toggleDebug(); + void toggleRaster(); box cornersToBox(uint32_t z) const; float getPixelRatio() const; diff --git a/include/llmr/map/source.hpp b/include/llmr/map/source.hpp index 7c997230b..653ff246e 100644 --- a/include/llmr/map/source.hpp +++ b/include/llmr/map/source.hpp @@ -24,6 +24,8 @@ public: raster }; + bool enabled; + public: Source(Map& map, Transform& transform, Painter& painter, Texturepool& texturepool, const char *url = "", float pixel_ratio = 1.0, Type type = Type::vector, std::list zooms = {0}, uint32_t tile_size = 512, uint32_t min_zoom = 0, uint32_t max_zoom = 14, bool enabled = true); @@ -56,7 +58,6 @@ private: uint32_t tile_size; uint32_t min_zoom; uint32_t max_zoom; - bool enabled; float pixel_ratio; diff --git a/ios/MBXViewController.mm b/ios/MBXViewController.mm index a9a809762..9f50ab479 100644 --- a/ios/MBXViewController.mm +++ b/ios/MBXViewController.mm @@ -203,7 +203,7 @@ class MBXMapView - (void)toggleRaster { -// mapView->map.toggleRaster(); + mapView->map.toggleRaster(); } - (void)dealloc diff --git a/src/map/map.cpp b/src/map/map.cpp index 05780b6c1..597504061 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -39,7 +39,7 @@ void Map::setup(float pixelRatio) { sources.emplace("streets", Source(*this, transform, painter, texturepool, "http://a.gl-api-us-east-1.tilestream.net/v3/mapbox.mapbox-streets-v4/%d/%d/%d.gl.pbf", pixelRatio, Source::Type::vector, {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14}, 512, 0, 14, true)); -// sources.emplace("raster", Source(*this, transform, painter, texturepool, "https://a.tiles.mapbox.com/v3/justin.map-pgygbwdm/%d/%d/%d%s.png256", pixelRatio, Source::Type::raster, {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21}, 256, 0, 21, true)); + sources.emplace("raster", Source(*this, transform, painter, texturepool, "https://a.tiles.mapbox.com/v3/justin.map-pgygbwdm/%d/%d/%d%s.png256", pixelRatio, Source::Type::raster, {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21}, 256, 0, 21, false)); } void Map::loadStyle(const uint8_t *const data, uint32_t bytes) { @@ -249,6 +249,15 @@ void Map::toggleDebug() { settings.persist(); } +void Map::toggleRaster() { + for (std::pair pair : sources) { + Source& source = pair.second; + source.enabled = !source.enabled; + } + + update(); +} + void Map::cancelAnimations() { transform.cancelAnimations(); } @@ -263,7 +272,9 @@ bool Map::updateTiles() { for (std::pair pair : sources) { Source& source = pair.second; - changed = source.update() || changed; + if (source.enabled) { + changed = source.update() || changed; + } } return changed;