Try this:

function getAngle(from, to){
 function wrapAngle(angle){
  if (angle>=360) {
   angle-=360;
  } else if (angle<0){
   angle+=360;
  }
  return angle;
 }
 var DEGREE_PER_RADIAN=57.2957795, RADIAN_PER_DEGREE=0.017453;
 var dLat=to.lat()-from.lat(), dLng=to.lng()-from.lng();
 var yaw=Math.atan2(dLng*Math.cos(to.lat()*RADIAN_PER_DEGREE),
dLat)*DEGREE_PER_RADIAN;
 return wrapAngle(yaw);
}

'from' and 'to' are both LatLng objects.

Martin.


On Feb 1, 9:54 pm, Marc Ridey <[email protected]> wrote:
> Seehttp://blog.mridey.com/2010/05/enabling-and-initializing-street-view....
>
> Just call panorama.setPov()
>
> one trick:
>
> You give StreetViewService the latlng of the location you would like to look
> at but StreetViewService comes back with the latlng of the location where
> the StreetView photos where taken. So you need to set the heading of the POV
> to the heading from where StreetView is to where you wanted to be.
> For that you need something 
> like:http://www.movable-type.co.uk/scripts/latlong.htmlor any formula
> calculating a bearing between two LatLngs.
>
> Marc
>
> On Tue, Feb 1, 2011 at 4:26 PM, Robert Poor <[email protected]> wrote:
> > @marc:
>
> > On Tue, Feb 1, 2011 at 12:14, Marc Ridey <[email protected]> wrote:
>
> > Check this on how to determine if a StreetView panorama exists for a given
> >> LatLng.
> >>http://blog.mridey.com/2010/11/using-streetviewservice-in-maps-api.html
>
> > Nice -- to summarize, call getPanoramaByLocation() and the status returned
> > in the callback function tells you if a StreetView is available at that
> > location.  Simple enough.
>
> > Now all I need is to figure out how to set the POV.  I'm pretty sure it's
> > not too difficult, but I haven't found a clean V3 example.
>
> > - ff
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Maps JavaScript API v3" group.
> > To post to this group, send email to
> > [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-maps-js-api-v3%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-maps-js-api-v3?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to