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

[android] - limit the scale factor for double tap zoom - #7580

Merged
tobrun merged 2 commits into
masterfrom
7514-double-tap-zoom
Jan 3, 2017
Merged

tobrun merged 2 commits into
masterfrom
7514-double-tap-zoom

Conversation

@tobrun

@tobrun tobrun commented Jan 3, 2017

Copy link
Copy Markdown
Member

Closes #7514, more information here.
Review @cammace

@tobrun tobrun added the Android Mapbox Maps SDK for Android label Jan 3, 2017
@tobrun tobrun added this to the android-v5.0.0 milestone Jan 3, 2017
@tobrun tobrun self-assigned this Jan 3, 2017
@tobrun
tobrun requested a review from cammace January 3, 2017 07:55

@zugaldia zugaldia left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of thoughts.

// around center map
transform.zoomBy(detector.getScaleFactor(), uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
float scaleFactor = detector.getScaleFactor();
if (scaleFactor > 0.65 && scaleFactor < 1.35) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobrun I like the approach of limiting the values provided by the gesture library to handle this behavior. Two thoughts:

  1. We're currently skipping updates when the scaleFactor is outside range. Wouldn't it work more smoothly if we clamp the value to the [min ,max] range?
  2. Why are we choosing 0.65 and 1.35 as the cutoff values?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. yes, will be smoother, I initially left this out because I was seeing negative values and thought that clamping those would give a reversed zoom, but after investigating these occurrences it's always followed with values resembling a reverse zoom so clamping here is valid.
01-03 18:13:12.049 18481-18481/com.mapbox.mapboxsdk.testapp E/MapGestureDetector$ScaleGestureListener: Before 0.70612484
01-03 18:13:12.050 18481-18481/com.mapbox.mapboxsdk.testapp E/MapGestureDetector$ScaleGestureListener: After 0.70612484
01-03 18:13:12.066 18481-18481/com.mapbox.mapboxsdk.testapp E/MapGestureDetector$ScaleGestureListener: Before 0.994616
01-03 18:13:12.067 18481-18481/com.mapbox.mapboxsdk.testapp E/MapGestureDetector$ScaleGestureListener: After 0.994616
01-03 18:13:12.081 18481-18481/com.mapbox.mapboxsdk.testapp E/MapGestureDetector$ScaleGestureListener: Before -0.1821847
01-03 18:13:12.082 18481-18481/com.mapbox.mapboxsdk.testapp E/MapGestureDetector$ScaleGestureListener: After 0.65
01-03 18:13:12.100 18481-18481/com.mapbox.mapboxsdk.testapp E/MapGestureDetector$ScaleGestureListener: Before 0.623573
01-03 18:13:12.101 18481-18481/com.mapbox.mapboxsdk.testapp E/MapGestureDetector$ScaleGestureListener: After 0.65
01-03 18:13:12.120 18481-18481/com.mapbox.mapboxsdk.testapp E/MapGestureDetector$ScaleGestureListener: Before 0.7911937
01-03 18:13:12.121 18481-18481/com.mapbox.mapboxsdk.testapp E/MapGestureDetector$ScaleGestureListener: After 0.7911937
01-03 18:13:12.134 18481-18481/com.mapbox.mapboxsdk.testapp E/MapGestureDetector$ScaleGestureListener: Before 0.88355064
01-03 18:13:12.135 18481-18481/com.mapbox.mapboxsdk.testapp E/MapGestureDetector$ScaleGestureListener: After 0.88355064
  1. purely based on values I'm seeing locally here on 3 devices. I have now moved them to the MapboxConstants file. FWIW the 0.65 value is the maximum scale we can zoom out, the 1.35 resembls the maximum scale we can zoom in. Feel free to test out changing these values while testing out this PR.

@cammace cammace left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Tested on device and looks good to merge

@tobrun
tobrun merged commit 654061c into master Jan 3, 2017
@jfirebaugh
jfirebaugh deleted the 7514-double-tap-zoom branch January 5, 2017 00:08
cammace pushed a commit that referenced this pull request Jan 25, 2017
* [android] - limit the scale factor to avoid accelerating the double tap zoom gesture

* clamp values
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Android Mapbox Maps SDK for Android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants