Did you read the documentation?
http://code.google.com/apis/maps/documentation/javascript/reference.html#StreetViewPanorama
Event visible_changed
--
Marcelo - http://maps.forum.nu
--
visibile_changed works somewhat but also fires at initialisation and
when you park the pegman etc.
This bug ..
http://code.google.com/p/gmaps-api-issues/issues/detail?id=2972&can=1&q=pegman&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Stars%20ApiType%20Internal
... describes a similar issues of detecting pegman dropping. Assuming
someone hasnt forgotten to close it, the issue still exists. It
mentions a work around by detecting the blue street view overlay which
sounds promising. But wasnt sure how to detect this.
Has anyone out there come across this issue and do you have any work
arounds?
Obviously, I don't know enough about what you're trying to achieve so
I can only answer based on the few lines of text that you posted.
A link to your map describing what you want to happen would help.
--
Marcelo - http://maps.forum.nu
--
> This bug ..http://code.google.com/p/gmaps-api-issues/issues/detail?id=2972&can=1...
If visible_changed doesn't suit your purposes then perhaps you can use
pano_changed and check getPosition() in the event handler. If you only
want to act on the first drop you can make "position" a global
variable and compare it to the last position in the event handler, for
example
var position; //global
var lastPosition = null; //global
// ...
var svp = new G.StreetViewPanorama(svpContainer,svpOptions);
G.event.addListener(svp, 'pano_changed', function(){
position = svp.getPosition();
if (typeof position != 'undefined') {
//pegman has been dropped on a valid position
if (lastPosition) {
// This is not the first drop. Do noting.
}
else {
// This is the first drop.
// add whatever action you want to take on the first drop
}
lastPosition = position;
}
else {
lastPosition = null;
}
});
--
Marcelo - http://maps.forum.nu
--
var G = google.maps; // global
// Sorry, I can't be bothered typing "google.maps." every time. ;-)
--
Marcelo - http://maps.forum.nu
--
> Marcelo -http://maps.forum.nu
On Dec 10, 3:22 pm, Marcelo <marcelo...@hotmail.com> wrote:
> var G = google.maps; // global
> // Sorry, I can't be bothered typing "google.maps." every time. ;-)
I wouldn't say this is laziness, it's good practice - as long as it is
not global.
I've added getPosition() and pano_changed etc to the fiddle - it
prints them out to see whats happening. Have a go.
http://jsfiddle.net/spiderplant0/UmPEq/17/
I guess my biggest issue is the firing of visibile_changed on page
load. I thought of ignoring it if its not followed by a
position_changed or something. But I cant think of a way that is not a
bit dodgy - so I rather have something a bit more robust.
An other idea was that mentioned in the bug report - detect insert_at
etc for the blue overlay loading. SOunds like it might be a bit over
complicated though. I've no idea how to do this. Any ideas?