Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add display option for map zoom buttons #630

Closed
barbeau opened this issue Jul 25, 2016 · 4 comments
Closed

Add display option for map zoom buttons #630

barbeau opened this issue Jul 25, 2016 · 4 comments

Comments

@barbeau
Copy link
Member

barbeau commented Jul 25, 2016

Summary:

User feedback:

Just updated from an older version, and found the zoom buttons have been removed, and I was unable to find my stop with one hand, and had to free up my other hand to use pinch to zoom

As a workaround, you can double-tap on the map, but on the 2nd tap hold on the screen, and then drag your thumb on the screen. It should zoom in and out.

For users that prefer buttons, it should be fairly simple to just add a display option to add them.

@barbeau barbeau modified the milestones: v2.1.x, v2.2 Jul 25, 2016
@m-yang
Copy link

m-yang commented Apr 4, 2018

Looking into adding this feature. Please bear with me as I'm a new contributor to the android open source community.

Would it be acceptable to add checkbox preference to show and hide the zoom buttons?

@barbeau
Copy link
Member Author

barbeau commented Apr 4, 2018

Welcome @matty-23! No worries, newcomers are always welcome.

Yes, I'd add a CheckboxPreference under the "Display" category that defaults to off, and when checked it shows the zoom control. IIRC you should just be able to add some code in BaseMapFragment.onResume() in the ... google... folder to check this preference and if checked call the method to enable the zoom control, and if unchecked disable it.

The main tricky part for this is making sure that the other views that slide on top of the map (e.g., when showing route on map, when tapping on stop on map) don't cover the zoom control when it's enabled. I think this is already implemented, but it would be the first thing to check when you have a working implementation. Also, feel free to open a work in progress PR and continue to push commits to the branch as you go. It makes it easier to provide feedback along the way.

@m-yang
Copy link

m-yang commented Apr 4, 2018

Setting uiSettings.setZoomControlsEnabled(true) in the BaseMapFragment puts the controls under the green my location FAB (see image) and I don't think it's possible to adjust the positioning of the default zoom controls.

Edit: I was able to add padding to move the controls to the left. Refer to this commit.

To get around this, I could:

  • Create custom zoom buttons adjacent to the FAB
  • Repurpose the volume buttons for zoom control (up for zoom in, down for zoom out)

First option makes the function visible to the user, but there can be issues with the other map layers covering the buttons as @barbeau mentioned in the previous post.

Second option doesn't add additional views the UI but we will have to make a decision on whether to disable volume control when the zoom controls are enabled.

Any thoughts on which is preferable?

@barbeau
Copy link
Member Author

barbeau commented Apr 5, 2018

Hmmm...ideally we'd be able to move the default zoom control to the bottom left corner (and when "Left hand mode" is enabled, swap to bottom right corner), but I think doing that by setting the map padding would result in strange behavior. It looks like you can reference the internal view IDs to move the default zoom control:
https://stackoverflow.com/a/14951848/937715

...but that's not officially supported and could break at any time if the SupportMapFragment code is changed.

So, it seems like the best solution would be to implement custom zoom buttons that look and behave exactly like the default zoom controls, but are aligned to the left instead of right. I believe SupportMapFragment and MapView from the Google Maps API are closed source, which makes this harder (otherwise you could just copy layout into OBA project).

themonki added a commit to themonki/onebusaway-android that referenced this issue Jun 5, 2018
* Based on commit 7aa3783 - Fix OneBusAway#630 - Add map zoom control with checkbox preference in settings (OneBusAway#867)
@themonki themonki mentioned this issue Jun 5, 2018
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants