Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

319
Views
Is it possible to resize a map in MapBox, maintain its aspect ratio and not change its zoom?

I'm trying to build a page with a map that responds to the user resizing the browser. When the window is smaller than a certain size, I want the map to shrink, maintain its aspect ratio (3:4) and zoom level (integer only). However, by modifying the CSS width and height of the map and the canvas, the map's edges start shrinking. I want the map to keep the same bounds.

I've tried something like this:

let bounds = map.getBounds();
//dynamically resize the map when the window is smaller than a certain width
map.resize();
map.fitBounds(bounds);

This code does 2/3 things: shrink and maintain aspect ratio, but the zoom level changes. Is there any way to do this? I was thinking of transforming the map contents without touching the zoom level of the map, but I don't know if that's possible.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!