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

Fixed Scale in Scale Control #7577

Closed
reyemtm opened this issue Nov 9, 2018 · 1 comment
Closed

Fixed Scale in Scale Control #7577

reyemtm opened this issue Nov 9, 2018 · 1 comment

Comments

@reyemtm
Copy link

reyemtm commented Nov 9, 2018

Static Scale Control

I want my maps to have a fixed scale, i.e. 1" = x ft or mi (ideally for printing, but that's another issue altogether). It looks like this was discussed in the initial scale control topic and mentioned in a way here.

I see this as something that could be added to the scale-control options. I have a working demo of this for devices where 1" equals 96px.

static: true,
maxWidth: 96

The adjustment to the scale control looks like this

let distance = (options && options.static === true) ? maxDistance.toFixed(0) : getRoundNum(maxDistance);
distance = (unit === 'mi') ? maxDistance.toFixed(2) : distance;
const ratio = (options && options.static === true) ? 1 : distance / maxDistance;

However I think this breaks down with different device PPI. Ideally units to pixels would be worked out in the control, but maybe this is not possible with JavaScript:

static: true,
staticWidth: 1,
staticUnits: 'in' //inches, pixels, centimeters, millimeters, throw an error is this would be larger than the map container

Going a bit deeper, it would be great to have this integrated into the map if possible so that calling

map.setScale(['1', '2000', 'in', 'ft']) //or something like that

would zoom the map to the appropriate zoom level that matches this scale.

@asheemmamoowala
Copy link
Contributor

this breaks down with different device PPI. Ideally units to pixels would be worked out in the control, but maybe this is not possible with JavaScript:

Based on this stackoverflow post, it seems that it is not possible to accurately determine the real DPI for a screen in the browser. Print may be another matter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants