Google street view URL - google-maps

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.

Related

Google Maps Static API - Custom zoom with markers

I am creating an application that downloads images from maps using the Google Maps Static API. I would want to decide the zoom level when having markers on the map (right now the zoom is set automatically so that all markers are shown in the image). Does anyone know if this is possible?
Right now the zoom is set automatically so that all markers are shown in the image
You are halfway there. Once done, get the resulting the zoom level: map.getZoom();
However, I think your app violates Google's terms as it is forbidden to copy their content.
According to the documentation, you can use the center and zoom parameters to configure the map (they aren't required with markers):
Location Parameters
center (required if markers not present) defines the center of the map, equidistant from all edges of the map. This parameter takes a location as either a comma-separated {latitude,longitude} pair (e.g. "40.714728,-73.998672") or a string address (e.g. "city hall, new york, ny") identifying a unique location on the face of the earth. For more information, see Locations below.
zoom (required if markers not present) defines the zoom level of the map, which determines the magnification level of the map. This parameter takes a numerical value corresponding to the zoom level of the region desired. For more information, see zoom levels below.
example URL:
https://maps.googleapis.com/maps/api/staticmap?center=42,-72&zoom=5&size=400x400&markers=color:blue%7Clabel:S%7C11211%7C11206%7C11222&format=jpg
resulting image:

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)

Automatic Google Street View Heading

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.

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

What parameters should I use in a Google Maps URL to go to a lat-lon?

I would like to produce a url for Google Maps that goes to a specific latitude and longitude. Now, I generate a url such as this:
http://maps.google.com/maps?z=11&t=k&q=58 41.881N 152 31.324W
The resulting map comes up with a round "A" balloon pointer, which seems to point to the nearest named object, and a green arrow, which points to the lat-lon. Sometimes, as in this example, the "A" pointer is centered and is far enough away that you cannot see the pointer to the lat-lon. (Zoom out to see both pointers in this example. The "A" pointer is in the center of Alaska, while the lat-long pointer is on Kodiak Island.)
Are there some parameters I can use in the Google Maps URL that will produce a single pointer to a designated lat-lon? (This loads in a separate window. It is not embedded.)
This is current accepted way to link to a specific lat lon (rather than search for the nearest object).
http://maps.google.com/maps?z=12&t=m&q=loc:38.9419+-78.3020
z is the zoom level (1-20)
t is the map type ("m" map, "k" satellite, "h" hybrid, "p" terrain, "e" GoogleEarth)
q is the search query, if it is prefixed by loc: then google assumes it is a lat lon separated by a +
yeah I had the same question for a long time and I found the perfect one. here are some parameters from it.
https://maps.google.com?parameter = value
q=
is used to specify the search query in Google maps search.
eg :
https://maps.google.com?q=newyork or
https://maps.google.com?q=51.03841,-114.01679
near=
is used to specify the location alternative to q=. Also has the added effect of allowing you to increase the AddressDetails Accuracy value by being more precise. Mostly only useful if query is a business or suchlike.
z=
Zoom level. Can be set 19 normally, but in certain cases can go up to 23.
ll=
Latitude and longitude of the map centre point. Must be in that order.
Requires decimal format. Interestingly, you can use this without q, in
which case it doesn’t show a marker.
sll=
Similar to ll, only this sets the lat/long of the centre point for a business search. Requires the same input criteria as ll.
t=
Sets the kind of map shown. Can be set to:
m – normal map,
k – satellite,
h – hybrid,
p – terrain
saddr=
Sets the starting point for directions searches. You can also add text into this in brackets to bold it in the directions sidebar.
daddr=
Sets the end point for directions searches, and again will bold any text added in brackets.You can also add "+to:" which will set via points. These can be added multiple times.
via=
Allows you to insert via points in directions. Must be in CSV format. For example, via=1,5 addresses 1 and 5 will be via points without entries in the sidebar. The start point (which is set as 0), and 2, 3 and 4 will all show full addresses.
doflg=
Changes the units used to measure distance (will default to the standard unit in country of origin). Change to ptk for metric or ptm for imperial.
msa=
Does stuff with My Maps. Set to 0 show defined My Maps, b to turn the My Maps sidebar on, 1 to show the My Maps tab on its own, or 2 to go to the new My Map creator form.
dirflg=
can set miscellaneous values below:
h - Avoid highway
t - Avoid tolls
reference
http://moz.com/ugc/everything-you-never-wanted-to-know-about-google-maps-parameters
In May 2017 Google announced the Google Maps URLs API that allows to construct universal cross-platform links. Now you can open Google maps on web, Android or iOS using the same URL string in form:
https://www.google.com/maps/search/?api=1&parameters
There are several modes that you can use: search, directions, show map and show street view.
So you can use something like
https://www.google.com/maps/search/?api=1&query=58.698017,-152.522067
to open map and place marker on some lat and lng.
For further details please refer to:
https://developers.google.com/maps/documentation/urls/guide
This should help with the new Google Maps:
https://maps.google.com/maps/place/<name>/#<lat>,<long>,15z/data=<mode-value>
The place adds a marker.
name could be a search term like "realtors"/"lawyers".
lat and long are the coordinates in decimal format and in that order.
15z sets zoom level to 15 (must be between 1 ~ 20).
You can enforce a particular view mode (map is default) - earth or terrain by adding these:
Terrain: /data=!5m1!1e4
Earth: /data=!3m1!1e3
E.g.: https://www.google.com/maps/place/Lawyer/#48.8187768,2.3792362,15z/data=!3m1!1e3
References:
https://moz.com/blog/new-google-maps-url-parameters
http://dddavemaps.blogspot.in/2015/07/google-maps-url-tricks.html
The following works as of April 2014. Delimiting each component of the URL with + and & for spaces and addition statements, respectively.
Full HTML:
<iframe src="http://maps.google.com/maps?q=Scottish+Rite+Hamilton+ON&loc:43.25911+-79.879494&z=15&output=embed"></iframe>
Broken down:
http://maps.google.com/maps?q=
where ?q= starts the general search, which I provide a venue, city, province info using + for spaces.
Scottish+Rite+Hamilton+ON
Next the geo-data. Lat and lng.
&loc:43.25911+-79.879494
Zoom level
&z=15
Required for iframes:
&output=embed
http://maps.google.com/maps?q=58%2041.881N%20152%2031.324W
Just use the coordinates as q-parameter. Strip the z and t prameters. While z should actually just be the zoom level, it seems that it won't work if you set any.
t is the map type. Having that said, it's not obvious how those parameters would affect the result in the shown way. But they do.
Maybe you should try the ll-parameter, but only decimal format will be accepted.
You can find a quick overview of all the parameters here.
If you need a name on your pin, you can also use:
http://maps.google.com/?q=MY%20LOCATION#lat,long
All the answers didn't work for me (the loc: and # options). So here is my solution for the new Google maps (April 2014)
Use the q= for query description, for example the street or the name of the place.
Use ll= for the lat, long coordinates.
You can add extra parameters like t=h (hybrid) and z=19 (zoom)
https://maps.google.com/?q=11+wall+street+new+york&ll=40.7060471,-74.0088901
https://maps.google.com/?q=new+york+stock+exchange&ll=40.7060471,-74.0088901
https://maps.google.com/?q=new+york+stock+exchange&ll=40.7060471,-74.0088901&t=h&z=19
There have been a number of changes, some incompatible, since I asked this question 5 years ago. Currently, the following works properly:
https://www.google.com/maps/place/58°41.881N 152°31.324W/#58.698017,-152.522067,12z/
The first latitude/longitude will be used for the pin location and label. It can be in degrees-minutes-seconds, degrees-minutes, or degrees. The second latitude/longitude (following the "#") is the map center. It must be in degrees only in order for the zoom (12z) to be recognized.
For terrain view, you can append "data=!4m2!3m1!1s0x0:0x0!5m1!1e4". I can find no documentation on this, though, so the spec could change.
New Version queries have a different format
To reach a lat long by url use (e.g.)
https://www.google.com/maps/search/-15.924,-5.719
works fine
https://maps.google.de/maps?q=51.404989,13.091751&z=17&t=k
This doesn't have to be much more complicated than passing in a value for the 'q' parameter. Google is a search engine after all and can handle the same stuff it handles when users type queries into its text boxes
"maps.google.com?/q=32.5234,-78.23432"
This works to zoom into an area more then drop a pin:
https://www.google.com/maps/#30.2,17.9820525,9z
And the params are:
#lat,lng,zoom
If you only have degrees minutes seconds you can pass them on the url :
https://maps.google.com/maps?q=latDegrees latMinutes latSeconds longDegrees longMinutes longSeconds
substitute in %20 for the spaces
"ll" worked best for me, see:
http://mapki.com/wiki/Google_Map_Parameters (query reference)
it shall not be too hard to convert minutes, seconds to decimal
http://en.wikipedia.org/wiki/Decimal_degrees
for a marker, possibly the best would be ?q=Description#lat,long