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

249
Visualizações
How to add remove zoomControl on google map base on size

I saw an the website of google that we could add/remove the zoomControl base on the map size. But the page doesn't explain how to do this.

My objective would be to remove the zoom control on smartphone, so under 576px I would like the zoom control to be hidden.

I'm working with angular but do not wish to subscribe to the screen size, but would like to let google do that on his self.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Google map doesn't accept such variable, but it's mentioned that the control will be hidden at 200px width, and to disable this you should explicitly mention it.

So if you wish to do that, you'll have to go with a little bit of javascript.

First check the screen width of device then set zoomControl property based on that. For example:-

function initMap(): void {
  let zoomControl = true;
  if(window.innerWidth < 576) zoomControl = false;
  const map = new google.maps.Map(
    document.getElementById("map") as HTMLElement,
    {
      zoom: 4,
      center: { lat: -33, lng: 151 },
      zoomControl: zoomControl,
      scaleControl: true,
    }
  );
}

declare global {
  interface Window {
    initMap: () => void;
  }
}
window.initMap = initMap;
about 4 years ago · Juan Pablo Isaza Relatório
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