make marker's info window initially opened and bind on click

38 views
Skip to first unread message

Yoke Lee

unread,
Oct 7, 2013, 3:40:07 AM10/7/13
to gothe...@googlegroups.com
Hi all

I'd like to make the info window opened on initial load, and bind it so that everytime user click on the marker, the same info window will open.
Below is my current approach.

If you have any smarter approaches, please let me know. Thanks.


// Create the Gothere map object.
var map = new GMap2(document.getElementById("map"));
// Create a geocoder.
var geocoder = new GClientGeocoder();
// Send a geocoding request.
geocoder.getLatLng("{name}", function(latlng) {
//console.log(latlng);
if (latlng) {
// Set the center of the map.
map.setCenter(latlng, 17);

// Add a marker to the map.
marker = new GMarker(latlng);
map.addOverlay(marker);
marker.openInfoWindowHtml("<h3>{name}</h3>" +
 "<p>{address} {postalcode}</p>",
 {maxWidth:200});
marker.bindInfoWindowHtml("<h3>{name}</h3>" +
 "<p>{address} {postalcode}</p>",
 {maxWidth:200});
}
}); 
Reply all
Reply to author
Forward
0 new messages