Streetview - pov automatically pointing at marker

826 views
Skip to first unread message

dbrb2

unread,
Jun 1, 2010, 3:49:57 AM6/1/10
to Google Maps JavaScript API v3
Hello,

I'm not sure whether the accuracy of the streetview system allows for
this - a streetview set to a specific lat/lon, as well as a marker on
the panorama at the same lat/lon.

I assume that when I call the streetview.setPosition the nearest
available streetview position is returned. Is there any way that I can
automatically set the POV of my streetview so that when it loads, it
is pointing towards the marker I have placed? Since both the marker
and the panorama have been requested using the same lat/lon I can't
calculate the bearing myself - unless I can find the actual lat/lon of
the panorama position I have ended up at...



Miguel Angel Vilela

unread,
Jun 1, 2010, 4:02:04 AM6/1/10
to google-map...@googlegroups.com

Hi,

When you request the nearest panorama to a point, you receive the LatLng of the panorama itself (inside it) and have the LatLng for which you requested the nearest panorama, then you can use both to calculate the bearing. As of now, you need to calculate this by yourself.

You might also be interested in this thread:

Cheers,
Miguel




--
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 google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

dbrb2

unread,
Jun 1, 2010, 8:21:33 AM6/1/10
to Google Maps JavaScript API v3
Thanks - yes, I tried the following:

Create a latlng point at a specified lat and lng:
var point = new google.maps.LatLng(lat,lng);

Create a maeker at that point:
var marker=new google.maps.Marker({position: point});

Place a marker at that point on the panorama
setMap(panorama)

Set the panorama to that location:
panorama.setPosition(point);

If I then compare the values of panorama.getPosition and
marker.position
alert(lng+" "+panorama.position.lng());
alert(lat+" "+panorama.position.lat());

The values will be identical - the panorama.position.lat() call
returns the ;position I requested, not the position that was actually
used.

Looking at the thread above, it would appear that if I put an event
listener on position.changed and then request panorama.position.xxx,
then I may be able to get the actual position of the panorama and from
thsi calculate the bearing... not sure logically why this should work,
but from the thread responses it seems worth a try. I'll give it a
go :-)


Set a panorama to be at that point

On Jun 1, 9:02 am, Miguel Angel Vilela <mig...@google.com> wrote:
> Hi,
>
> When you request the nearest panorama to a point, you receive the LatLng of
> the panorama itself (inside it) and have the LatLng for which you requested
> the nearest panorama, then you can use both to calculate the bearing. As of
> now, you need to calculate this by yourself.
>
> You might also be interested in this thread:http://groups.google.com/group/google-maps-js-api-v3/browse_thread/th...
>
> Cheers,
> Miguel
>
> On Tue, Jun 1, 2010 at 09:49, dbrb2 <benjamin.bar...@gmail.com> wrote:
> > Hello,
>
> > I'm not sure whether the accuracy of the streetview system allows for
> > this - a streetview set to a specific lat/lon, as well as a marker on
> > the panorama at the same lat/lon.
>
> > I assume that when I call the streetview.setPosition the nearest
> > available streetview position is returned. Is there any way that I can
> > automatically set the POV of my streetview so that when it loads, it
> > is pointing towards the marker I have placed? Since both the marker
> > and the panorama have been requested using the same lat/lon I can't
> > calculate the bearing myself - unless I can find the actual lat/lon of
> > the panorama position I have ended up at...
>
> > --
> > 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
> > google-map...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2Bunsu...@googlegroups.com>
> > .

dbrb2

unread,
Jun 1, 2010, 8:46:55 AM6/1/10
to Google Maps JavaScript API v3
Thanks - yes, I tried the following:

Create a latlng point at a specified lat and lng:
var point = new google.maps.LatLng(lat,lng);

Create a maeker at that point:
var marker=new google.maps.Marker({position: point});

Place a marker at that point on the panorama
setMap(panorama)

Set the panorama to that location:
panorama.setPosition(point);

If I then compare the values of panorama.getPosition and
marker.position
alert(lng+" "+panorama.position.lng());
alert(lat+" "+panorama.position.lat());

The values will be identical - the panorama.position.lat() call
returns the ;position I requested, not the position that was actually
used.

Looking at the thread above, it would appear that if I put an event
listener on position.changed and then request panorama.position.xxx,
then I may be able to get the actual position of the panorama and from
thsi calculate the bearing... not sure logically why this should work,
but from the thread responses it seems worth a try. I'll give it a
go :-)


Set a panorama to be at that point

On Jun 1, 9:02 am, Miguel Angel Vilela <mig...@google.com> wrote:
> Hi,
>
> When you request the nearest panorama to a point, you receive the LatLng of
> the panorama itself (inside it) and have the LatLng for which you requested
> the nearest panorama, then you can use both to calculate the bearing. As of
> now, you need to calculate this by yourself.
>
> You might also be interested in this thread:http://groups.google.com/group/google-maps-js-api-v3/browse_thread/th...
>
> Cheers,
> Miguel
>
> On Tue, Jun 1, 2010 at 09:49, dbrb2 <benjamin.bar...@gmail.com> wrote:
> > Hello,
>
> > I'm not sure whether the accuracy of the streetview system allows for
> > this - a streetview set to a specific lat/lon, as well as a marker on
> > the panorama at the same lat/lon.
>
> > I assume that when I call the streetview.setPosition the nearest
> > available streetview position is returned. Is there any way that I can
> > automatically set the POV of my streetview so that when it loads, it
> > is pointing towards the marker I have placed? Since both the marker
> > and the panorama have been requested using the same lat/lon I can't
> > calculate the bearing myself - unless I can find the actual lat/lon of
> > the panorama position I have ended up at...
>
> > --
> > 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
> > google-map...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-maps-js-a...@googlegroups.com<google-maps-js-api-v3%2Bunsu...@googlegroups.com>
> > .

Marc Ridey

unread,
Jun 2, 2010, 5:16:11 AM6/2/10
to Google Maps JavaScript API v3
The new StreetViewService will help you do this:

var streetViewLocation = new google.maps.LatLng(-33.867386,
151.195767);
var nearestLatLng = null;
var nearestPano = null;
var client = new google.maps.StreetViewService();
client.getNearestPanorama(streetViewLocation, 50, function(result,
status) {
if (status == google.maps.StreetViewStatus.OK) {
nearestPano = result.location.pano;
nearestLatLng = result.location.latLng;
}
});

nearestLatLng will contains the nearest Street View panorama available
within 50m of the streetViewLocation LatLng given in
getNearestPanorama.

On Jun 1, 5:49 pm, dbrb2 <benjamin.bar...@gmail.com> wrote:
> Hello,
>
> I'm not sure whether the accuracy of thestreetviewsystem allows for
> this - astreetviewset to a specific lat/lon, as well as a marker on
> the panorama at the same lat/lon.
>
> I assume that when I call thestreetview.setPosition the nearest
> availablestreetviewposition is returned. Is there any way that I can
> automatically set the POV of mystreetviewso that when it loads, it

Marc Ridey

unread,
Jun 11, 2010, 6:32:33 PM6/11/10
to Google Maps JavaScript API v3
Note: StreetViewService.getNearestPanorama was released during Google
IO. It has now been renamed StreetViewClient.getPanoramaByLocation to
be more consistent with its behavior and match getPanoramaById.
http://code.google.com/apis/maps/documentation/javascript/reference.html#StreetViewService

Nathan Raley

unread,
Jun 14, 2010, 12:39:39 PM6/14/10
to google-map...@googlegroups.com
Is this pushed to the current version?  I am getting a:
StreetViewClient is null or not an object when trying to perform the following:
userPoint = google.maps.StreetViewClient.getPanoramaByLocation(latlng);

--
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 google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages