I am currently working on an interactive photomap using prettyPhoto to show pictures when a point on the map is clicked. Some of the points will show 1 photo and others will show multiple. I had everything working fine if I only use one photo, but now I am adjusting to call multiple photos on the ones that have it, but Im running into an issue with making a prettyPhoto api call. Heres my current code:
$(document).ready(function(){
var baseUrl = "http://ninjastatus.com/last_stop/Bronx/"
var checkMultiple = function (stop) {
if (stop.imgName && stop.imgName.match('|')) {
var images = stop.imgName.split('|');
for (var i = images.length - 1; i >= 0; i--) {
images[i] = baseUrl + images[i].replace('\t\n', '').trim();
};
return images;
}
if (stop.imgName && stop.imgName.replace('\t\n', '').trim() !== undefined) {
var images = baseUrl + stop.imgName.replace('\t\n', '').trim();
return images;
}
}
for(var i=0; i<stations.length; i++){
var loc = stations[i].loc;
var name = stations[i].name;
var imgs = checkMultiple(stations[i]);
var desc = "test description";
$('#subway').append('<a href="#" alt="' + name + '" title="' + name +
'" onclick="$(this).prettyPhoto(imgs,name,desc); return false;">
<area shape="circle" coords="' + loc + '" nohref="nohref" /></a>');
}
$('img[usemap]').rwdImageMaps();
})
I get an invalid character error for the line containing the onclick. I know all the data coming in from the stations variable is correct the issue is in making the prettyPhoto call itself. Is there a way to do this with a normal jquery click function while retaining the correct variables for each link? Or would it be better to use html data attributes, and write a jquery click function to pull those and call prettyPhoto?
You can find the prettyPhoto api documentation here:
http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/documentation
You can also find the page here: http://adminref.com/NYCPhotoMap/index.html
Looks like I was able to figure it out. The main issue was I wasn't initiating prettyPhoto and I also changed the format of the js objects being pulled in to simplify the code. Well here's the final code I ended up getting:
You can check out the custom map I made for my buddy, an artist in New York. He took pictures of all the subway stations throughout NYC and the points on the map link to each stations pics in a prettyPhoto gallery. Click there to check it out --> http://adminref.com/NYCPhotoMap/index.html