2

One of my applications shows multiple location markers on a Google map. How can I show an InfoWindow after a short delay?

Here is my script:

google.maps.event.addListener(marker, 'mouseover', onMarkerClick);

//create a function that will open an InfoWindow for a marker mouseover
var onMarkerClick = function() {
    var marker = this;
    var latLng = marker.getPosition();
    infowindow.setContent(
        '<h3>Marker position is:</h3>' + latLng.lat() + ', ' + latLng.lng());
    infowindow.open(map, marker);
};
Sean Mickey
  • 7,618
  • 2
  • 32
  • 58
Aadi
  • 6,959
  • 28
  • 100
  • 145

1 Answers1

5

setTimeout should do what you want. The number is the millisecond delay.

setTimeout(function() { infowindow.open(map, marker) }, 500);
Heitor Chang
  • 6,038
  • 2
  • 45
  • 65
  • 1
    Remember that you also need to clear the set timouts when new mouseover events are triggered. More info can be found in this answer. http://stackoverflow.com/questions/5786646/stop-function-that-run-with-settimeout – Philip Aug 02 '13 at 07:37