Then once you have the nearest Street View you can use this function
to determine the POV angle to set your Street View to so it points to
your marker:

  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);
  }

Pass it the lat,lng (from) of of the nearest Street View returned by
the StreetViewService() and use your marker lat,lng as the 'to'
parameter and it'll give you an angle to set the Street View to when
it opens.

Martin.


Chad Killingsworth wrote:
> You'll want to use the StreetViewService class. See
> http://code.google.com/apis/maps/documentation/javascript/reference.html#StreetViewService
>
> Specifically, you'll use the getPanoramaByLocation method. Use the
> marker position as your location. One of the problems you'll likely
> encounter is creating a proper closure on your marker event listener.
> A search of these forums will give you the solution there.
>
> Chad Killingsworth
>
> On Oct 2, 7:23 am, duncanm <[email protected]> wrote:
> > I've managed to get this far:
> >
> > http://www.midwinterdesign.net/sample2.html
> >
> > I can create a link that changes the map to streetview, however It's
> > centered on the centre of the map, and not on each individual icon.
> >
> > Does anyone know what I must do to set each link to open at the lat -
> > long of each marker?
> >
> > Thanks,
> >
> > D.
> >
> > --
> >
> > On Oct 1, 10:57 pm, duncanm <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi,
> >
> > > I have a map with the following structure:
> >
> > >http://www.midwinterdesign.net/sample.html
> >
> > > and I would like to add a <a> link into the info window of each marker
> > > that changes the map view to streetview centred on the marker (as if I
> > > had dragged the pin man icon on to the marker)
> >
> > > Is this possible?
> >
> > > I already have the following data for each icon:
> >
> > > pov: {
> > >         heading: -127,
> > >         pitch: 5.8,
> > >         zoom: 0.5 }

-- 
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