I can't use the PhotoListWidget methods

90 views
Skip to first unread message

buscadordeturismo

unread,
Dec 20, 2011, 9:14:40 PM12/20/11
to panora...@googlegroups.com
Hi, I'm Esteban from Argentina, I'm using the PhotoListWidget ok, but I can only use the setPosition(0) method, all the rest give me troubles, they just return NULL, or Undefined, or a mistake...

Here is the code

var widget_1 = new panoramio.PhotoListWidget('wapiblock', myRequest_1, myOptions);
widget_1.setPosition(0);
var test = widget_1.getPosition();
alert(test);

I tried getAtEnd, getAtStart or getPhotos but I was given the same results...

What I want to do in the script is to know if the widget have some pictures or if its empty.

Thanks !
Message has been deleted

QuentinUK

unread,
Jan 30, 2012, 4:51:42 PM1/30/12
to panora...@googlegroups.com
You have to give time for the widget to ask whether there are any photos to display.

The best way to do this is to add a listener. This will report to your program when it has finished setting the position. You need to calllisten before setPosition.

function photoChanged(event){
    // event.target==widget_1 if there is only 1 widget
    var photo=event.target.getPhoto();
    if(photo){
         alert('Photo "' + photo.getPhotoTitle() + '" is displayed');
    }
    else{
         alert("No photos");
    }
});

panoramio.events.listen(widget_1, panoramio.events.EventType.PHOTO_CHANGED, photoChanged); 

widget_1.setPosition(0);// call after setting the listener

Reply all
Reply to author
Forward
0 new messages