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

Update ScaleControl unit of distance on the fly #6137

Closed
ryanhamley opened this issue Feb 13, 2018 · 2 comments
Closed

Update ScaleControl unit of distance on the fly #6137

ryanhamley opened this issue Feb 13, 2018 · 2 comments

Comments

@ryanhamley
Copy link
Contributor

ryanhamley commented Feb 13, 2018

Motivation

It should be possible to programatically change the ScaleControl's unit of distance and have the ScaleControl instantly update. This is helpful for applications that may need to show scale's in different units based on a site's location.

Design Alternatives

You could remove the scale and add it back when you want to change the unit.

Alternatively, you could provide a method to update the scale's internal unit and update the scale.

Design

Removing and re-adding the control is inefficient and can result in layout issues if multiple controls are in the same container. Updating the internal unit is fairly straightforward and only requires calling the existing updateScale method. I believe exposing this method is the proper way to achieve this goal.

Mock-Up

N/A

Concepts

N/A

Implementation

Proposed pull request here

@ryanhamley ryanhamley mentioned this issue Feb 13, 2018
4 tasks
@kriscarle
Copy link

In case it helps anyone, I've put together a custom scale control that shows metric and imperial at the same time, along with cursor coordinates https://github.com/maphubs/mapbox-gl-dual-scale-control

image

@jfirebaugh
Copy link
Contributor

This was added in #6274.

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

4 participants