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

ScaleControl ignores maxWidth when using nautical units and scale < 1 nm #7438

Closed
MichaelHedman opened this issue Oct 18, 2018 · 5 comments
Closed

Comments

@MichaelHedman
Copy link
Contributor

MichaelHedman commented Oct 18, 2018

mapbox-gl-js version: 0.50.0

browser: Chrome 69.0.3497.100 (Official Build) (64-bit)

Steps to Trigger Behavior

  1. Add a ScaleControl to the map like so: map.addControl(new mapboxgl.ScaleControl({ unit: 'nautical' })
  2. Zoom in to zoomlevel 12+.
  3. The scalebar stays at 1 nm but grows indefinitely.

Expected Behavior

Alternative 1: For scales < 1 nm the scalebar should respect the maxWidth and instead display decimal units, like 0.5 nm and so on.
Alternative 2: For scales < 1 nm the scalebar should respect the maxWidth and instead switch to an alternative unit, for example 'metric'.
Alternative 3: For scales < 1 nm the scalebar should respect the maxWidth and instead display scale in cable length units.
I'm not sure which alternative I like best, but probably alt. 1.

Actual Behavior

Scalebar never displays units smaller than 1 nm, and instead grows horizontally indefinitely.

@mourner
Copy link
Member

mourner commented Oct 18, 2018

@MichaelHedman option 1 sounds good to me! Want to submit a PR for this?

@MichaelHedman
Copy link
Contributor Author

I think it's just a matter of fixing the getRoundNum() function in scale_control.js. I'll give it a try. This will of course then apply to all units, not only nautical.

@MichaelHedman
Copy link
Contributor Author

@mourner I have a fix ready, but I'm unable to push my feature branch. I'm getting:
remote: Permission to mapbox/mapbox-gl-js.git denied to MichaelHedman.
fatal: unable to access 'https://github.com/mapbox/mapbox-gl-js.git/': The requested URL returned error: 403

Any idea?

@mourner
Copy link
Member

mourner commented Oct 23, 2018

@MichaelHedman you need to fork the repository (see the Fork button on the top right), change your GitHub client repo settings so that it points to your fork instead of the main repo, and push there. Then you can create a pull request.

@MichaelHedman
Copy link
Contributor Author

I created a pull request #7469.

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