views:

1697

answers:

2

I have a Google map and street view based on provided lat/lng coordinates, zoom, yaw and pitch. I need to invoke a javascript to update a hidden field for each of these values whenever any of the details change from their default or when a button is clicked.

So whenever the map/street view is zoomed in, panned, tilted etc it outputs the new details.

How do I call the functions getPOV(), yawchanged(yaw:Number), pitchchanged(pitch:Number), and zoomchanged(zoom:Number) whenever the Street View is changed (similar to moveend for Maps)

+2  A: 

I generally have found that "moveend" is the best event to use as a hook to get the state of the map when a user changes it. I will need to look up how to get the lat/lng, zoom, yaw, and pitch from the map isntanct when I have more time this afternoon

// map is the instance of your GMap2
GEvent.addListener(map, 'moveend', function() {
  var center = map.getCenter();
  var zoom = map.getZoom();

  alert([center.lat(), center.lng(), zoom].join(','));
});
howardr
will give it a go, thanks for the contribution
Peter
That works great for maps, I now need the exact equivalent of moveend for street view to output either getPOV() or yawchanged(yaw:Number), pitchchanged(pitch:Number), and zoomchanged(zoom:Number)
Peter
A: 

Not sure of the best way to compress this but this works to get the changed details:

GEvent.addListener(myPano, 'initialized', function(pano) {
  alert("newlng: " + pano.latlng.lng() + ", newlat: " + pano.latlng.lat());
});

GEvent.addListener(myPano, 'yawchanged', function(newyaw){
  alert("yawchanged: " + newyaw);
});

GEvent.addListener(myPano, 'pitchchanged', function(newpitch) {
  alert("pitchchanged: " + newpitch);
});

GEvent.addListener(myPano, 'zoomchanged', function(newzoom) {
  alert("zoomchanged: " + newzoom);
});
Peter