-
Notifications
You must be signed in to change notification settings - Fork 19
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 #4
Comments
Hi @reyemtm , I'm currently having the same issue. Did you find a way to fix a scale? |
Updated. Please read new comment. I ended up figuring out with trial and error what zoom levels result in what scale, and then having a dropdown to choose a scale for the printed map, with the map then zooming to the appropriate zoom level for the requested print scale. This is a rough estimate but good enough for my purposes. //1" = x ft to map zoom level
var scales = {
20:20.8,
50:19.7,
100:18.46,
200:17.55
}; This only works because my maps are limited to a small geographic area. As you move around the globe the scale ratios will change. There is probably a way to figure out what the resulting scale would be regardless of geographic area and screen resolution, but I did not mess with figuring that out. I was also using a custom version of mapbox gl js with a fixed scale control. I have since stopped using this custom version and am not printing a scale control at all. For the maps printed with a known scale I just put 1" ~ x' in the attribution which gets printed with the map. If you find a better method please share! |
Fixed! Ok, sort of fixed. For proper scales (i.e. 1 inch = 200ft), the key is to adjust the scale mapbox-print-pdf/js/map-utils.js Line 100 in a6237ac
fitBounds() method for proper scales across devices, mainly due to this issue. So the key is to delete this line and add an option to the renderMap that passes the current map zoom to the print map.
This works well for a small area, but more work would be needed if you wanted to have proper zoom levels to print map scales for a larger area as the ratios will change depending on the longitude and latitude. |
Is there a way to force the map to print at the current map scale (or setting a map scale) instead of having it resizing to fit the document size? I am working on getting a fixed scale (1" to x ft or mi) on my print maps. This is one of the last pieces of that I still need in order to not have to open a desktop client to print a simple map.
The text was updated successfully, but these errors were encountered: