Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google maps-api v3 InfoWindow automatically open on page load

Tags:

I am working on a project where I am using the Google Maps api-v3 , On the map there will be a few place markers containing information that I am storing in an InfoWindow.

I am wondering is there anyway that you can set an InfoWindow to automatically open on the page load (i.e automatically open without user interaction).

Searching online all I can seem to find is that it needs to be tied to an event listener but all the events the InfoWindow object seems to have are mouse events.

Does anyone know of a workaround of sorts ?

like image 928
scrineym Avatar asked Apr 26 '12 23:04

scrineym


People also ask

How do I get rid of infowindow in Google Maps?

The user can click the close button on the InfoWindow to remove it from the map, or the developer can call close() for the same effect.

How do I put infowindow on marker?

Move an info windowAttach the info window to a new marker using the InfoWindow. open() method. Note: If you call open() without passing a marker, the InfoWindow will use the position specified upon construction through the InfoWindowOptions object literal.


1 Answers

Not sure I fully understand your question but this works for me with a hard-coded LatLng:

var infoWindow = null; function initialize()  {     infoWindow = new google.maps.InfoWindow();     var windowLatLng = new google.maps.LatLng(43.25,-68.03);     infoWindow.setOptions({         content: "<div>This is the html content.</div>",         position: windowLatLng,     });     infoWindow.open(map);  } // end initialize  google.setOnLoadCallback(initialize); 
like image 165
Eric Bridger Avatar answered Oct 07 '22 18:10

Eric Bridger