Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

328
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda