From e5d9a20c7c3282a7b058ef40c2ade3429f04f99d Mon Sep 17 00:00:00 2001 From: "Justin R. Miller" Date: Thu, 3 Jul 2014 19:02:46 -0700 Subject: [PATCH] native-side map change notifications --- include/llmr/platform/platform.hpp | 4 ++-- ios/mapbox-gl-cocoa | 2 +- src/map/transform.cpp | 18 ++++++++++++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/llmr/platform/platform.hpp b/include/llmr/platform/platform.hpp index 8db0d34b9..138843fee 100644 --- a/include/llmr/platform/platform.hpp +++ b/include/llmr/platform/platform.hpp @@ -48,8 +48,8 @@ std::shared_ptr request_http(const std::string &url, // Cancels an HTTP request. void cancel_request_http(const std::shared_ptr &req); -// Notifies a watcher of map x/y/scale/rotation changes. -void notify_map_change(); +// Notifies a watcher of map changes. +void notify_map_change(MapChange key); // Shows an alpha image with the specified dimensions in a named window. void show_debug_image(std::string name, const char *data, size_t width, size_t height); diff --git a/ios/mapbox-gl-cocoa b/ios/mapbox-gl-cocoa index f9dec39f7..0d472e64d 160000 --- a/ios/mapbox-gl-cocoa +++ b/ios/mapbox-gl-cocoa @@ -1 +1 @@ -Subproject commit f9dec39f77186edf132348ca58697c511a3827b4 +Subproject commit 0d472e64d643af90a96a7eb7988e372947336fc6 diff --git a/src/map/transform.cpp b/src/map/transform.cpp index c7bbbfdf7..72449956d 100644 --- a/src/map/transform.cpp +++ b/src/map/transform.cpp @@ -28,6 +28,8 @@ bool Transform::resize(const uint16_t w, const uint16_t h, const float ratio, if (final.width != w || final.height != h || final.pixelRatio != ratio || final.framebuffer[0] != fb_w || final.framebuffer[1] != fb_h) { + platform::notify_map_change(platform::MapChangeRegionWillChange); + current.width = final.width = w; current.height = final.height = h; current.pixelRatio = final.pixelRatio = ratio; @@ -35,7 +37,9 @@ bool Transform::resize(const uint16_t w, const uint16_t h, const float ratio, current.framebuffer[1] = final.framebuffer[1] = fb_h; if (!canRotate() && current.angle) _setAngle(0); constrain(current.scale, current.y); - platform::notify_map_change(); + + platform::notify_map_change(platform::MapChangeRegionDidChange); + return true; } else { return false; @@ -76,7 +80,9 @@ void Transform::_moveBy(const double dx, const double dy, const timestamp durati std::make_shared>(current.y, final.y, current.y, start, duration)); } - platform::notify_map_change(); + platform::notify_map_change(duration ? + platform::MapChangeRegionDidChangeAnimated : + platform::MapChangeRegionDidChange); } void Transform::setLonLat(const double lon, const double lat, const timestamp duration) { @@ -294,7 +300,9 @@ void Transform::_setScaleXY(const double new_scale, const double xn, const doubl Bc = s / 360; Cc = s / (2 * M_PI); - platform::notify_map_change(); + platform::notify_map_change(duration ? + platform::MapChangeRegionDidChangeAnimated : + platform::MapChangeRegionDidChange); } #pragma mark - Constraints @@ -388,7 +396,9 @@ void Transform::_setAngle(double new_angle, const timestamp duration) { current.angle, final.angle, current.angle, start, duration)); } - platform::notify_map_change(); + platform::notify_map_change(duration ? + platform::MapChangeRegionDidChangeAnimated : + platform::MapChangeRegionDidChange); } double Transform::getAngle() const {