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

234
Visualizações
How to stop a user initiating multiple calls to google map api

I have come across an issue with google maps.

I have an HTML form which displays a large amount of data for a user. The form is split into a concertina layout, with each concertina responsible for showing different aspects of the user's data.

One of these concertinas holds the user's address and a google map with several pins representing pertinent information.

If the form is loaded, and the concertina is closed, then google map <div> has no vertical height on which to calculate zoom settings and I end up with a map that is zoomed to the extents of the planet. If the concertina is open when the form is loaded then zoom works fine (because the map <div> has height).

This is a well known feature/bug. One way to get around this is to load the google map when the user opens the concertina or if the concertina is open when the form is loaded.

What I need to achieve: I need to prevent multiple calls to google maps to 'reload' the map if the user opens and closes the concertina multiple times (without refreshing the form).

Here is a fiddle: https://jsfiddle.net/fdnuopzv/4/

As you can see the google map is loaded EVERY time the concertina opens. I need to detect that the map exists so that it shows the existing map rather than going and getting a fresh one.

I tried using:

if (!google.map) {
  map_init();
}

but this does not have the desired affect.

As a point of interest if you move the map_init() line from line 10 to line 65 you can see how a zero height breaks the google zoom.

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

0

This is pretty lo-fi, but one option is to check the container for an iframe ...

if ($('#accordianarea' + thisId).find('iframe').length===0) map_init();

https://jsfiddle.net/kinglish/cw2Lamxr/5/

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