Charles
Charles

Reputation: 446

gmaps4rails trigger side bar click event

I'm using gmaps4rails sidebar function to allow jumping to individual marker on the map.

My question is:

how can I trigger the click event on the first sidebar item so the 1st marker's info window will be display by default?

Upvotes: 1

Views: 514

Answers (1)

apneadiving
apneadiving

Reputation: 115541

You should just add a callback:

Gmaps.map.callback = function() {
  var firstMarker = Gmaps.map.markers[0];
  var map         = Gmaps.map.map;
  firstMarker.infowindow.open(map, firstMarker.serviceObject);
}

Be sure to put this callback after the gmaps helper in your view.

Upvotes: 1

Related Questions