diff --git a/include/llmr/map/map.hpp b/include/llmr/map/map.hpp index 1af6b3c54..defc1bef1 100644 --- a/include/llmr/map/map.hpp +++ b/include/llmr/map/map.hpp @@ -59,6 +59,8 @@ public: void setDefaultTransitionDuration(uint64_t duration_milliseconds = 0); void setStyleJSON(std::string newStyleJSON); std::string getStyleJSON() const; + void setAccessToken(std::string access_token); + std::string getAccessToken() const; // Transition void cancelTransitions(); @@ -166,6 +168,7 @@ private: Painter painter; std::string styleJSON = ""; + std::string accessToken = ""; bool debug = false; timestamp animationTime = 0; diff --git a/include/llmr/map/source.hpp b/include/llmr/map/source.hpp index 2937a8f69..f74624925 100644 --- a/include/llmr/map/source.hpp +++ b/include/llmr/map/source.hpp @@ -23,7 +23,8 @@ class Texturepool; class Source : public std::enable_shared_from_this, private util::noncopyable { public: Source(SourceType type = SourceType::Vector, const std::string &url = "", - uint32_t tile_size = 512, uint32_t min_zoom = 0, uint32_t max_zoom = 22); + uint32_t tile_size = 512, uint32_t min_zoom = 0, uint32_t max_zoom = 22, + const std::string &access_token = ""); bool update(Map &map); void updateMatrices(const mat4 &projMatrix, const TransformState &transform); @@ -35,7 +36,7 @@ public: std::forward_list getIDs() const; void updateClipIDs(const std::map &mapping); - static std::string normalizeSourceURL(const std::string &url); + static std::string normalizeSourceURL(const std::string &url, const std::string &access_token); public: const SourceType type; diff --git a/include/llmr/style/style.hpp b/include/llmr/style/style.hpp index 37a50485b..cfaba1898 100644 --- a/include/llmr/style/style.hpp +++ b/include/llmr/style/style.hpp @@ -16,6 +16,7 @@ namespace llmr { +class Map; class Sprite; class Source; class StyleLayer; @@ -27,7 +28,7 @@ public: struct exception : std::runtime_error { exception(const char *msg) : std::runtime_error(msg) {} }; public: - Style(); + Style(Map &map); void loadJSON(const uint8_t *const data); @@ -63,6 +64,7 @@ private: private: + Map ↦ std::set> activeSources; PropertyTransition defaultTransition; bool initial_render_complete = false; diff --git a/include/llmr/style/style_parser.hpp b/include/llmr/style/style_parser.hpp index 10cd3d2e8..27dfd4757 100644 --- a/include/llmr/style/style_parser.hpp +++ b/include/llmr/style/style_parser.hpp @@ -17,6 +17,7 @@ namespace llmr { enum class ClassID : uint32_t; +class Map; class StyleLayer; class StyleLayerGroup; @@ -24,6 +25,8 @@ class StyleParser { public: using JSVal = const rapidjson::Value&; + StyleParser(Map &map); + void parse(JSVal document); std::shared_ptr getLayers() { @@ -92,6 +95,8 @@ private: std::forward_list parseValues(JSVal values); private: + Map ↦ + std::unordered_map constants; std::unordered_map> sources; diff --git a/src/map/map.cpp b/src/map/map.cpp index 516e8fe03..b1f22235b 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -22,7 +22,7 @@ using namespace llmr; Map::Map(View& view) : view(view), transform(), - style(std::make_shared