Automatic Google Street View Heading - google-maps

Is there an easy way to get Street View to automatically set the heading like the Street View Image API does?
I have Google Street View images embedded in my application and I would like to put a link on them that will direct the user to the full Google Street View, preferably with the same heading. So far I can link to full Street View with the coordinates but not the heading, since I don't know the heading.
For a certain coordinate, the Street Map Image API will give me an image pointed at the coordinates given. For example:
http://maps.googleapis.com/maps/api/streetview?size=300x150&location=38.9506254,-76.942316
Using the an unofficial resource (http://moz.com/ugc/everything-you-never-wanted-to-know-about-google-maps-parameters) I can create a link to Google Street View, but I must provide a heading angle, which I don't have. Here's an example with the Street View window parameters left off.
http://maps.google.com/maps?q=&layer=c&cbll=38.9506254,-76.942316
This works but does not give me a heading pointing toward the coordinates. Instead, it points due north. I assume I can host my own Street View page and get the heading as a vector from the nearest panorama to the target, as it appears Street View Image API does. I would rather not if I don't have to if I can just embed a single link.
Also, is it safe to use the google map URL parameters? They appear to be undocumented, but I can find references to the parameters I am using back in 2008 so they seem stable.
Edit:
To further elaborate on the difference between full Street View with URL parameters and Street View Image API, here's a diagram of what I get from both without specifying a heading.
Street View Image API will automatically point the POV camera at the target from the nearest Street View panorama when no heading is provided. Full Street View, through URL parameters without heading, will point the POV camera due north. I am looking for a easy way to mimic the Street View Image API behavior with Street View through URL parameters without having to pull panorama location information from google, though that looks like the only option.

If you know the heading that you want you can add a heading parameter in the querystring. Quoting from Google docs:
Heading indicates the compass heading of the camera. Accepted values are from 0 to 360 (both values indicating North, with 90
indicating East, and 180 South). If no heading is specified, a value
will be calculated that directs the camera towards the specified
location, from the point at which the closest photograph was taken.

Related

Can we set the heading and rotation of a Google Maps Embed street view using the UI's provided by Google?

Embedded Google Maps street views are no longer working on a client's side because the response from maps.google.com includes a X-Frame-Options: SAMEORIGIN header.
I've attempted to use Google's Maps Embed API page (https://developers.google.com/maps/documentation/embed/start) so that this client can generate these street views automatically for a given address, but the results from this page have the street view camera angled at a completely different address, and rotating the camera is never captured in the final URL that is generated.
Is there a recommended way of capturing a street view embed link that includes heading / rotation now that embedding directly from maps.google.com doesn't work? I should point out that these can be set by hand, but it would require transcribing them from the normal maps.google.com UI into these new generated embed URLs.
The Embed API documentation defines the following optional parameters:
The following URL parameters are optional:
heading indicates the compass heading of the camera in degrees clockwise from North. Accepted values are from -180° to 360&deg.
pitch specifies the angle, up or down, of the camera. The pitch is specified in degrees from -90° to 90°. Positive values will angle the camera up, while negative values will angle the camera down. The default pitch of 0° is set based on on the position of the camera when the image was captured. Because of this, a pitch of 0° is often, but not always, horizontal. For example, an image taken on a hill will likely exhibit a default pitch that is not horizontal.
fov determines the horizontal field of view of the image. The field of view is expressed in degrees, with a range of 10° - 100°. It defaults to 90°. When dealing with a fixed-size viewport the field of view is can be considered the zoom level, with smaller numbers indicating a higher level of zoom.
Adding those to the request works for me (the wizard just doesn't create them for me)

API to display the nearest photos to a long/lat location from Google Maps Views (like Panoramio)

Forgive me if this has already been asked but searching on 'Google Maps Views' brings up rather a lot of irrelevant hits.
Is there an API to display the nearest (say) 5 photos to a particular long/lat location from the photos available on Google Maps Views? I don't particularly need them on a map, just to embed thumbnails of the photos and link to the originals.
eg I have a page for Callanish stone circle. Could I embed images from Views based on a long/lat query?
Here's what is on Views for that location:
https://www.google.com/maps/views/explore?hl=en&gl=gb&vm=1&ll=54.596562,-3.104517&bd=54.586641,-3.121855,54.606481,-3.087179&z=15&pv=2
I read that Views is what is supposed to be taking over from Panoramio. I know Panoramio had an API but that's being shut down.
If this is possible, does anyone have an example of something similar? Showing photos on a map would be OK if that's the only way to do it.
Many thanks
Andy
http://www.megalithic.co.uk/article.php?sid=42
The Google Maps API can do it and the imagery carousel at the bottom of Google Maps website is a good example of it.
Nearest photos
You can retrieve the nearest photos to a location using the Places Photo feature, which is part of the Places library. As you want multiple photos, you need to use Place Details requests - function getDetails(). It will return up to ten PlacePhoto objects.
You probably want to submit a small height/width since you create thumbnails. And send another request with a larger height/width when a thumbnail is clicked.
Nearest Street View panorama
If, by chance, a road close to Callanish stone circle has been photographed by Street View, you can add this imagery as well.
Requests for Street View panoramas include a radius parameter. The callback function returns the nearest imagery within the requested radius. See this example. Thereby, you can retrieve one panorama by passing a very large radius.

Google maps search by address component

I have implemented a basic google places autocomplete in my web app, for example saying "Heraclion, Crete" and it translates it to the latlng coordinates that I want. I also used the mysql radius example from the api to show nearest entries. I also have locations in a second area of Crete, called "Rethymnon".
The problem now is the following. Supposedly one types just Crete. How can I get all the entries from Heraclion and Rethymnon? My code uses the radius approach as mentioned before. So I need something else to define it in a rectangular area.
Is this possible?
If the result contains a viewport (LatLngBounds), you could use that.
PlaceResult
geometry: The Place's geometry-related information. This includes:
location provides the latitude and longitude of the Place.
viewport defines the preferred viewport on the map when viewing this Place

Street view google map URL and coordinate query

I am currently converting a number of simple Google Map Street View links into URL requests for static Street View images. Most of the conversions work except for a few odd instances which I am struggling to explain.
Firstly, in the normal way, I access Google Maps as a regular user and find the position on a road in London I want to see called London Wall, and I point upwards and eastwards. This is the resulting link: (please test it and you will see a prominent building called Winchester House with a smooth curved exterior in the flash Street View used by Google consumers):
http://maps.google.com/maps?q=Winchester+House,+London+Wall,+London,+United+Kingdom&hl=en&ll=51.516287,-0.083299&spn=0.007838,0.018196&sll=51.522309,-0.080509&sspn=0.06227,0.145569&oq=winchester+house,+london+wall&hq=Winchester+House,&hnear=Wall,+1+Denbigh+Rd,+London+W11+2SJ,+United+Kingdom&t=m&z=16&layer=c&cbll=51.516305,-0.083422&panoid=U6g4EoZt5cM4e2WFiDLoxA&cbp=12,268.2,,0,-16.66
Secondly, if I adopt the same coordinates from the above link to get a Static Street View Photo via the following URL request, I get a different result:
http://maps.googleapis.com/maps/api/streetview?size=800x600&location=51.516305,%20-0.083422&fov=110&heading=268.2&pitch=16.66&sensor=false
This second view is still looking westwards along London wall, but the Static Street View photo is set approximately 50+ metres on the wrong global coordinate (please try the link above and you will see a footbridge is in front of Winchester House, which lies in the distance).
This is confusing when both URLs above appear to be using the same global coordinates. (I have referenced the same coordinates for many other different links and both URLs usually show the same view).
I would be grateful for anyone's help on this and understand whether anyone has experienced similar problems or inconsistencies with different Google coordinates.
Many thanks
Mike

Google street view URL

Hi I have the address of a property and my application can launch a browser to go to http://maps.google.com?q=searchStringHere. If a good match is found it will take it directly there. Is there any thing I can append to the url to make it switch to streetview without having the exact coordinates? I dont't want to code any javascript or flash.
Building a Google Street View URL
Basic Google Map URL
http://maps.google.com/maps?q=
q= Query - anything passed in this parameter is treated as if it had been typed into the query box on the maps.google.com page.
Basic url to display GPS cords location
http://maps.google.com/maps?q=31.33519,-89.28720
http://maps.google.com/maps?q=&layer=c
layer= Activates overlays. Current options are "t" traffic, "c" street view. Append (e.g. layer=tc) for simultaneous.
http://maps.google.com/maps?q=&layer=c&cbll=
cbll= Latitude,longitude for Street View
http://maps.google.com/maps?q=&layer=c&cbll=31.33519,-89.28720
http://maps.google.com/maps?q=&layer=c&cbll=31.335198,-89.287204&cbp=
cbp= Street View window that accepts 5 parameters:
Street View/map arrangement, 11=upper half Street View and lower half map, 12=mostly Street View with corner map
Rotation angle/bearing (in degrees)
Tilt angle, -90 (straight up) to 90 (straight down)
Zoom level, 0-2
Pitch (in degrees) -90 (straight up) to 90 (straight down), default 5
The one below is: (11) upper half Street View and lower half map, (0) Facing North, (0) Straight Ahead, (0) Normal Zoom, (0) Pitch of 0
This one works as is, just change the cords and if you want to face a different direction (the 0 after 11)
http://maps.google.com/maps?q=&layer=c&cbll=31.335198,-89.287204&cbp=11,0,0,0,0
For more Google Street View code interpertation
Unfortunately not - there's no simple answer, based on the address.
Firstly, the list of parameters for the Google Maps site is documented here, so you can use that as your starting point.
The easy part is that you need to select the streetview layer "&layer=c".
However, before anything will display in that layer, you need to specify where your view is. You set the position by the latitude and longitude in cbll and the angle of the camera with some options in cbp.
To get the latitude and longitude from the address, you need to use a geocoding service, like the google maps api.
However, this will only get you a street view close to the address. In addition to knowing where the street view needs to be from, you also need to know which angle to point the camera at - this will be different for every address, depending on where the nearest point the StreetView camera took a photo from was, so it's not easy to do automatically (with any information that I know is available...)
UPDATE 07/2019:
Solution of 10/2018 still works for me as of now, but I have found an official documented way to construct the Street View URL:
Forming the Street View URL
https://www.google.com/maps/#?api=1&map_action=pano&parameters
Parameters
map_action=pano (required): Specifies the type of view to display. Maps and Street View share the same endpoint. To ensure a panorama is displayed, the action must be specified as pano.
One of the following URL parameters is also required:
viewpoint: The viewer displays the panorama photographed closest to the viewpoint location, specified as comma-separated latitude/longitude coordinates (for example 46.414382,10.013988). Because Street View imagery is periodically refreshed, and photographs may be taken from slightly different positions each time, it's possible that your location may snap to a different panorama when imagery is updated.
pano: The specific panorama ID of the image to display. If you specify a pano you may also specify a viewpoint. The viewpoint is only used if Google Maps cannot find the panorama ID. If pano is specified but not found, and a viewpoint is NOT specified, no panorama image is displayed. Instead, Google Maps opens in default mode, displaying a map centered on the user's current location.
The following URL parameters are optional:
heading: Indicates the compass heading of the camera in degrees clockwise from North. Accepted values are from -180 to 360 degrees. If omitted, a default heading is chosen based on the viewpoint (if specified) of the query and the actual location of the image.
pitch: Specifies the angle, up or down, of the camera. The pitch is specified in degrees from -90 to 90. Positive values will angle the camera up, while negative values will angle the camera down. The default pitch of 0 is set based on on the position of the camera when the image was captured. Because of this, a pitch of 0 is often, but not always, horizontal. For example, an image taken on a hill will likely exhibit a default pitch that is not horizontal.
fov: Determines the horizontal field of view of the image. The field of view is expressed in degrees, with a range of 10 - 100. It defaults to 90. When dealing with a fixed-size viewport, the field of view is considered the zoom level, with smaller numbers indicating a higher level of zoom.
Example 1: Uses only a viewpoint to specify location.
https://www.google.com/maps/#?api=1&map_action=pano&viewpoint=48.857832,2.295226&heading=-45&pitch=38&fov=80
Source: https://developers.google.com/maps/documentation/urls/guide
(scroll to the bottom for Street View URLs)
Update 10/2018
The GET API (see Haygood's answer) seems to be outdated but some calls still seem to work.
Base URL:
changed to http://www.google.com/maps (map.google.com/maps still works but redirects)
Parameters:
q: is ignored, can be skipped
For more Google Street View code interpertation
layer: The parameter must be set to c (t is no more supported and breaks it)
cbll: latitude and longitude (unchanged)
cbp: only parameter 2 (rotation angle) and 5 (pitch) are still supported
is ignored, can be 0 or empty string
Rotation angle/bearing (in degrees)
is ignored, can be 0 or empty string
is ignored, can be 0 or empty string
Pitch (in degrees) -90 (straight up) to 90 (straight down)
Updated examples: http://www.google.com/maps?layer=c&cbll=31.335198,-89.287204
or http://www.google.com/maps?layer=c&cbll=31.335198,-89.287204&cbp=,30,,,20 with rotation 30 and pitch 20.
You can get the values by pressing the link button at the top of the street view.