My question: Is the following the only solution?
I made a Gmap page with Views that display a lot of places. Every places contains a slideshow (multiple imageField) that I usely display with LightBox2 module. A summary of every node is display inside Gmap little popup when clicking on a marker (normal behavior).
Unfortunality the code inside this popup is dynamicaly inserted so the "Lightbox links" (ie href="image.jpg" rel="light....) aren't effective.
After some research I found that I need to call Lightbox.initList() after the content insertion. So here is what I did:
I modified marker.js from GMap Module (I know it's bad but I really didn't find any better solution to reach the click on marker event) and inserted after marker.marker.openInfoWindowHtml(marker.text); line 64, the following line :
if (marker.text.search('rel="light')) onGmapPopupOpen('Lightbox.initList()',0,5,2000);
and somewhere (I did it in the marker.js file but I guess you can do it whereever you want) (CAREFUL I used some JQuery code) :
function onGmapPopupOpen(action,mytime,step,maxtime) {
if ($('.gmap-popup').length>0) eval(action);
else if (mytime<maxtime) setTimeout("onGmapPopupOpen('"+action+"',"+(mytime+step)+","+step+","+maxtime+")",step);
}
Mainly what it does is if the content of the popup to be inserted contains rel="light (that means there some lightbox behaviour) and when a click on a marker is made, it waits for the popup to be displayed before executing the Lightbox.initList() .
I know it's not straight forward, the best way would have been to write a patch to the GMap module to raise an event and then bind Lightbox.initList() to the new event but I really didn't have time to spend on that (nor the knowledge). Maybe someone could do it, I guess it's an interesting event to have (enabling javascript execution after gmap popup loads).
Did I miss something and there's a better solution?
Hope it helps.
Thierry.
Comments
Is there another way to catch "click on marker"'s event?
Is there another way to catch "click on marker"'s event?
interested. subscribing...
interested. subscribing...
This is actual for me too
This is actual for me too
I try this solution but
I try this solution but doesn't work, any suggestion?
For Drupal 7
A few comments from my experience getting this to work in D7:
Maybe these are obvious, but it took me a bit to figure out.
Other then that this fix worked good for me.
fail to apply on drupal 7
can anyone help with this one?
thanks!
Any success on D7
I have a similar use case and would love to have a more customizable lightbox popup for Gmap markers vs. the current dynamic generated one.