information cloud to show on marker on load
alexkb - September 16, 2009 - 02:48
| Project: | Google Maps Tools |
| Version: | 6.x-2.x-dev |
| Component: | Documentation |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Does anyone know if its possible to have the Cloud window within a gmap display on page load, rather then only after the user clicks the marker?
I'm pretty sure its possible with the google maps api by simply doing this:
marker.openInfoWindowHtml(html);
Thanks.

#1
Add a custom js to the page and do:
Drupal.gmaps.map.behaviors.exampleBehavior = function(gmi) {//select which map do we want to handle
if (gmi.getContainer()[0].id == 'example_dom_id') {
//select the proper marker
var marker = gmi.overlays.marker['example_marker_id'];
var handler = new GMapsMarkerActionHandlerContent(marker);
handler.click();
}
};
Without marker id:
Drupal.gmaps.map.behaviors.exampleBehavior = function(gmi) {//select which map do we want to handle
if (gmi.getContainer()[0].id == 'example_dom_id') {
$.each(gmi.overlays.marker, function() {
var handler = new GMapsMarkerActionHandlerContent(this);
handler.click();
//break the loop after the first iteration
return false;
});
}
};
#2
That worked great, thanks xmarket!
For anyone that wants to find the dom id, simply add an alert before the if condition:
Drupal.gmaps.map.behaviors.exampleBehavior = function(gmi) {
//select which map do we want to handle
alert(gmi.getContainer()[0].id );
if (gmi.getContainer()[0].id == 'example_dom_id') {
//select the proper marker
var marker = gmi.overlays.marker['example_marker_id'];
var handler = new GMapsMarkerActionHandlerContent(marker);
handler.click();
}
};
And if you're looking for the name of the example_marker_id, simply look through your inline javascript in your html source for a reference to "marker" like so:
"marker": { "<this is your marker id>": { "basic":...Cheers.
- Alex
#3
It's a little bit easier if you have firebug. On its DOM tab you can find all of the map definitions at Drupal.settings.gmaps.map.{map_id}.overlays.marker.{marker_id}.
Of course, there are usually multiple maps and multiple markers per map.