Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ilex01's avatar

From click to $( document ).ready(function()

How Do I transform this click code bellow to actually load on document ready?

google.maps.event.addListener(marker, 'click', (function(marker, i) {
            return function() {
                infowindow.setContent('locations[i][0]);
                infowindow.open(map, marker);
            }
        })(marker, i));
0 likes
4 replies
Sinnbeck's avatar

Put it inside that document ready function from your topic?

Sinnbeck's avatar

@ilex01 something like (just copy paste of your code)

$( document ).ready(function() {
google.maps.event.addListener(marker, 'click', (function(marker, i) {
            return function() {
                infowindow.setContent('locations[i][0]);
                infowindow.open(map, marker);
            }
        })(marker, i)); 
})
ilex01's avatar

No I want to load the markers setContent on load and not on click

Please or to participate in this conversation.