Yaelede
Yaelede

Reputation: 19

How to display infoWindow on GoogleMaps v3 when the map loads?

I have a simple Google map v3 with only one marker with this code:

google.maps.event.addListener(myplaceMarker, 'click', function() {
infowindow.open(map,myplaceMarker);

With this code, info window opens when I click on the marker. How can I make the info window show up automatically when the map loads on the page?

SOLVED: I just needed to remove the first row.

Upvotes: 1

Views: 742

Answers (2)

Rajesh Gheware
Rajesh Gheware

Reputation: 157

Another way to open the infoWindow when map loads or from any other event ( like when selecting a row where you have some results that has got location relation), then you invoke below piece of code. This means your infoWindow is associated with marker for 'click' event and you can trigger this 'click' event from anywhere based on your requirements.

google.maps.event.trigger(marker,'click');

Upvotes: 1

nodrog
nodrog

Reputation: 3532

Make the call to open the map outside of the listener, else it will be set to happen when the marker object is clicked.

Upvotes: 0

Related Questions