-1

We have a google maps V3 map. With a ground overlay in a function. We have a menu with items and i want when clicked on a link the groundoverlay appear and when click again, dissapear.

This is my code so far but it doesn't work yet.

Any tips ?

function Radarlaag() {
radarOverlay.setMap(null);
radarOverlay.setMap(map);
}

And this is my HTML code:

<li><a href="#" class="icon radar" id="radar_box" onclick="Radarlaag();">Radar</a></li>

Thanks!

user3408380
  • 345
  • 1
  • 5
  • 18

1 Answers1

0

Your link calls the Radarlaag function which does:

radarOverlay.setMap(null); - Removes the overlay
radarOverlay.setMap(map); - Adds the overlay

With the getMap method you should be able to do something like:

function Radarlaag() {

    if (radarOverlay.getMap()) {

        radarOverlay.setMap(null);

    } else {

        radarOverlay.setMap(map);
    }
}

This is untested.

Edit: you are also calling Radarlaag in the setTimeout function so that will just turn it on and off every sec. I don't know if this is an attempt to refresh the GIF file?

MrUpsidown
  • 19,965
  • 12
  • 63
  • 114