diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2015-12-20 02:01:18 -0800 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2015-12-20 03:57:51 -0800 |
commit | b7223f249ddd714f344a00ce4da00dafb44cc7fb (patch) | |
tree | 54bb5406cf2d5614cbd10e2d3f5e094adab186fd /platform | |
parent | d668c0fa8482c86a2a73e5fc9661e32d89f26c56 (diff) | |
download | qtlocation-mapboxgl-b7223f249ddd714f344a00ce4da00dafb44cc7fb.tar.gz |
[ios, osx] Avoid transition to current camera
Fixes #2456.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/darwin/MGLMapCamera.mm | 24 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 10 | ||||
-rw-r--r-- | platform/osx/src/MGLMapView.mm | 6 |
3 files changed, 40 insertions, 0 deletions
diff --git a/platform/darwin/MGLMapCamera.mm b/platform/darwin/MGLMapCamera.mm index 6ebd16ce77..e32ef5a10c 100644 --- a/platform/darwin/MGLMapCamera.mm +++ b/platform/darwin/MGLMapCamera.mm @@ -98,4 +98,28 @@ NSStringFromClass([self class]), self, _centerCoordinate.latitude, _centerCoordinate.longitude, _altitude, _heading, _pitch]; } +- (BOOL)isEqual:(id)other +{ + if ( ! [other isKindOfClass:[self class]]) + { + return NO; + } + if (other == self) + { + return YES; + } + + MGLMapCamera *otherCamera = other; + return (_centerCoordinate.latitude == otherCamera.centerCoordinate.latitude + && _centerCoordinate.longitude == otherCamera.centerCoordinate.longitude + && _altitude == otherCamera.altitude + && _pitch == otherCamera.pitch && _heading == otherCamera.heading); +} + +- (NSUInteger)hash +{ + return (@(_centerCoordinate.latitude).hash + @(_centerCoordinate.longitude).hash + + @(_altitude).hash + @(_pitch).hash + @(_heading).hash); +} + @end diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 7dbce7d2e3..84b82a6404 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1750,6 +1750,11 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion { + if ([self.camera isEqual:camera]) + { + return; + } + _mbglMap->cancelTransitions(); mbgl::CameraOptions options = [self cameraOptionsObjectForAnimatingToCamera:camera]; if (duration > 0) @@ -1778,6 +1783,11 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) - (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion { + if ([self.camera isEqual:camera]) + { + return; + } + _mbglMap->cancelTransitions(); mbgl::CameraOptions options = [self cameraOptionsObjectForAnimatingToCamera:camera]; if (duration >= 0) diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index e0d44a2717..b0f402ff7a 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -946,6 +946,9 @@ public: - (void)setCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration animationTimingFunction:(nullable CAMediaTimingFunction *)function completionHandler:(nullable void (^)(void))completion { _mbglMap->cancelTransitions(); + if ([self.camera isEqual:camera]) { + return; + } mbgl::CameraOptions options = [self cameraOptionsObjectForAnimatingToCamera:camera]; if (duration > 0) { @@ -974,6 +977,9 @@ public: - (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration completionHandler:(nullable void (^)(void))completion { _mbglMap->cancelTransitions(); + if ([self.camera isEqual:camera]) { + return; + } mbgl::CameraOptions options = [self cameraOptionsObjectForAnimatingToCamera:camera]; if (duration >= 0) { |