如何在Gmap V3中稍微延迟后加载InfoWindow?

Aad*_*adi 2 google-maps infowindow google-maps-api-3 google-maps-markers

我的一个应用程序在Google地图上显示了多个位置标记.如何在短暂延迟后显示InfoWindow?

这是我的脚本:

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);
};
Run Code Online (Sandbox Code Playgroud)

Hei*_*ang 5

setTimeout应该做你想做的事.数字是毫秒延迟.

setTimeout(function() { infowindow.open(map, marker) }, 500);
Run Code Online (Sandbox Code Playgroud)