Working! - Opening a lightbox window from an infoWIndow

688 views
Skip to first unread message

Mark

unread,
Feb 25, 2012, 10:44:13 AM2/25/12
to Google Maps JavaScript API v3
I had seen some posts with questions about how to open up a lighbox
from a click within an infoWindow, but had not seen any solutions so
thought that I would post.

First off I found a post which discusses the issues here (http://
www.umaitech.com/cms/?p=41), but the code and examples are for Maps
API V2 and an older version of slimbox. But a little reading on the
current version of slimbox (jQuery based version), specifically the
API call to open and I was able to get it working.

The code to create the marker ended up looking like this:

function createMarker(latlng, name, address, thumbImage, couponImage)
{

var marker = new google.maps.Marker({
map : map,
position : latlng,
title : name
});


var div = document.createElement('div');
var html = "<b>" + name + "</b> <br/>"
+ "<a onclick='jQuery.slimbox(\""+ couponImage + "\",
\"Caption");return false'>"
+ "<img src='" + thumbImage + "'></a>";

div.innerHTML = html;

google.maps.event.addListener(marker, 'click', function() {
infoWindow.setContent(div);
infoWindow.open(map, marker);
});

return marker;
}
Reply all
Reply to author
Forward
0 new messages