I'm looking for a way to get the default heading in the Google Maps Streetview Embed with the same accuracy/heading as the static Streetview.
For a project I'm using the Google Maps static Streetview API to create a snapshot/front facing view of an address. The way I do this is to first find the address LatLng with the Google GeoCode API, using the full address (streetname+house_number+house_number_addition+zipcode+city). With the latLng I then call the Static streetview API to fetch a snapshot of this location.
https://maps.googleapis.com/maps/api/streetview?size=900x600&location={$latLng}&key={$key}"
As you can see there is no heading param specified so the API determines the best possible heading based on the given LatLng, as specified in the API docs.
The result is spot on for 99% of the cases, in which the house is almost perfectly centered in the streetview snapshot.
The Google maps streetview embed has a very different result. The steps leading up to the creation of the embed URL are identical (find the latlng based on the full address, and use the LatLng as the location in the embedcode)
https://www.google.com/maps/embed/v1/streetview?key={$key}&location={$latLng}"
resulting in the iframe HTML
<iframe src='{https://www.google.com/maps/embed/v1/streetview?key={$key}&location={$latLng}"}' width='600' height='450' frameborder='0' style='border:0;' allowfullscreen='' aria-hidden='false' tabindex='0'></iframe>
In this case the heading or camera direction is in many (not all) cases almost facing opposite of the targeted house. Of course this can be adjusted using the heading param, but it's strange that both streetview API's differ so much in the chosen heading.
After some more digging I found the answer here. The solution is to first use the Directions API to navigate to the given location, which sets the heading facing the location. Then use the getPanoramaByLocation method of the StreetviewService to determine the correct heading.
So instead of constructing the embed code serverside, the best approach seems to create the Streetview in the frontend using the Google Maps API.
The same URL gives different results via Mobile & Desktop.
A certain URL format for street view displays different results on different devices.
This is a starting reference for the URL's format: Google street view URL
When I load this URL:
http://maps.google.com/maps?q=&layer=c&cbll=40.741895,-73.989308
in chrome via Desktop: I get a street view of a beach
in chrome via Android Mobile device: I get a street view of a street in New York (the correct response)
It seems that google presents via desktop a view (photo) that was made by a user and via Mobile a photo that was made by google.
But in another url:
http://maps.google.com/maps?q=&layer=c&cbll=32.0522032,34.7633459
in chrome via Desktop: I get the correct street view, made by google
in chrome via Android Mobile device: "No results found for your search"
I guess this bug doesn't effect Google because they use a different entry point for street views in their services...
My goal is to present a Google Street View in a webview in an Android app and I'm trying to get the correct URL format for that.
Does anyone know what is the correct format?
The officially supported and recommended by Google way is using Google Maps URLs. Google Maps URLs allow create universal cross-platform URLs that can be used both on desktop and mobile devices and support street view mode
The pano action lets you launch a viewer to display Street View images as interactive panoramas. Each Street View panorama provides a full 360-degree view from a single location. Images contain 360 degrees of horizontal view (a full wrap-around) and 180 degrees of vertical view (from straight up to straight down). The pano action launches a viewer that renders the resulting panorama as a sphere with a camera at its center. You can manipulate the camera to control the zoom and the orientation of the camera.
You example may be rewritten using Google Maps URLs
https://www.google.com/maps/#?api=1&map_action=pano&viewpoint=40.741895,-73.989308
However, unfortunately, it gives me a beach street view on desktop. I believe this is a data issue on Google side and you can report a problem to Google using the Report a problem link in bottom right corner of the map.
In the meantime I can suggest the following workaround. You can use Street View API metadata service to get a pano ID of the point you are interested in
E.g. https://maps.googleapis.com/maps/api/streetview/metadata?location=40.741895%2C-73.989308&source=outdoor&key=YOUR_API_KEY
Note that this service is free of charge and doesn't consume your quota
Street View Static API metadata requests are free to use. No quota is consumed when you request metadata.
Also it supports a source parameter that allows filter out non-Google panoramas. In aforementioned example I get the following metadata response
{
"copyright":"© Google, Inc.",
"date":"2017-11",
"location":{
"lat":40.7419078,
"lng":-73.9893223
},
"pano_id":"qH-ml27SSSYEXUCTT2NrhQ",
"status":"OK"
}
So, now I can create a Google Maps URL using a pano ID that will open expected street view panorama
https://www.google.com/maps/#?api=1&map_action=pano&pano=qH-ml27SSSYEXUCTT2NrhQ
I hope this helps!
Is it possible to have a google map embeded street view panorama of a given address in your page?
All the codes I have came across work with coordination, I'm looking for "address", since if you just use coordination you will have to set pov and all that,
Google seems to do that itself, look at the panorama picture here:
http://maps.google.ca/maps/place?hl=en&sugexp=kjrmc&cp=10&gs_id=z&xhr=t&biw=1680&bih=874&gs_upl=&bav=on.2,or.r_gc.r_pw.,cf.osb&um=1&ie=UTF-8&q=toyota+calgary&fb=1&gl=ca&hq=toyota&hnear=0x537170039f843fd5:0x266d3bb1b652b63a,Calgary,+AB&cid=16440335169618939517&ei=VpqYTpPsLbCrsALi0LnqBA&sa=X&oi=local_result&ct=map-marker-link&resnum=1&sqi=2&ved=0CF8QrwswAA
Thanks
Yes, using the Google Maps Javascript API V3. Take a look here: http://code.google.com/apis/maps/documentation/javascript/services.html#StreetView
You can also embed Street View on your page by just using Google Maps.
Search for the address on Google Maps.
Go to the Street View for the location.
Click the link button in the upper-right hand corner above the map.
Click the 'Customize and preview embedded map' link.
A new page will open up with some customization opens and the code to embed the map/image on your page.
Yes you can. All you need is a google decoder who will decode your address. Another way is to directly pass your address as a part of the url to google.
When using decoder, you will get the result in the form of a latitude longitude object which you can use to reset/set your map's marker
There is no way to accurately set the heading automatically and no way to set the pitch and fov (field of view) - BUT if you figure these out manually you can create a URL that fetches a static image with those settings from Google
Take a look at this tutorial on the Street View Image API
I have a small application that gives the current location: longitude and latitude.
Now I have to browse to google maps with the longitude and latitude.
Please suggest how I can do this.
The best way is to use q parameter so that it displays the map with the point marked. eg.:
https://maps.google.com/?q=<lat>,<lng>
This schema has changed again (23rd October 2018). See Kushagr's answer for the latest.
This for a map with the marker (via aaronm's comment):
https://www.google.com/maps/?q=-15.623037,18.388672
For an older example (no marker on this one):
https://www.google.com/maps/preview/#-15.623037,18.388672,8z
The oldest format:
http://maps.google.com/maps?ll=-15.623037,18.388672&spn=65.61535,79.013672
As of today (1st November, 2020), Google provided a provision of Universal URL which works quite efficiently on cross-platforms and thus, Google recommends this method.
Syntax: https://www.google.com/maps/search/?api=1&query=<lat>,<lng>
Example :
https://www.google.com/maps/search/?api=1&query=28.6139,77.2090
(New Delhi, India)
Documentation/Source.
As of today (2014/09/23), I've found that to get marker on exact place (not an approximation) you can use:
http://www.google.com/maps/place/49.46800006494457,17.11514008755796
Additionally, if you want to specify map center and zoom:
http://www.google.com/maps/place/49.46800006494457,17.11514008755796/#49.46800006494457,17.11514008755796,17z
If you want to use satellite map type, then append /data=!3m1!1e3
http://www.google.com/maps/place/49.46800006494457,17.11514008755796/#49.46800006494457,17.11514008755796,17z/data=!3m1!1e3
And If you want terrain view of the map, then append /data=!3m1!4b1
https://www.google.com/maps/place/49.46800006494457,17.11514008755796/#49.46800006494457,17.11514008755796,17z/data=!3m1!4b1
If you want to open Google Maps in a browser:
http://maps.google.com/?q=<lat>,<lng>
To open the Google Maps app on an iOS mobile device, use the Google Maps URL Scheme:
comgooglemaps://?q=<lat>,<lng>
To open the Google Maps app on Android, use the geo: intent:
geo:<lat>,<lng>?z=<zoom>
It´s out of the scope of the question, but I think it might be also interesting to know how to link to a route. The query would look like this:
https://www.google.es/maps/dir/'52.51758801683297,13.397978515625027'/'52.49083837044266,13.369826049804715'
These are URLs that work:
http://maps.google.com/?q=<LAT>,<LNG>
https://maps.google.com/?q=<LAT>,<LNG>&ll=<LAT>,<LNG>&z=18
https://www.google.com/maps/#<LAT>,<LNG>,16z
https://maps.google.com/?q=<LAT>,<LNG>&z=16
Although (for avid readers) This is the latest from google (August 22 2017):
Maps URLs
Maps URLs with map display
Maps URLs with search action
From google
Search: When searching for a specific place, the resulting map puts a pin in the specified location and displays available place details.
Important: The parameter api=1 identifies the version of Maps URLs this URL is intended for. This parameter is required in every request. The only valid value is 1. If api=1 is NOT present in the URL, all parameters are ignored and the default Google Maps app will launch, either in a browser or the Google Maps mobile app, depending on the platform in use (for example, https://www.google.com/maps).
This works too:
https://www.google.pl/maps/#<lat>,<lon>,<zoom>z
Example.
With pointer:
https://www.google.com/maps/place/<lat>,<lon>/#<lat>,<lon>,<zoom>z
Example.
To open the google maps app in android:-
geo:<lat>,<lng>?z=<zoom>
open app with marker for give location:-
geo:<lat>,<lng>?q=<lat>,<lng>(Label,Name)
open google map in ios:-
comgooglemaps://?q=<lat>,<lng>
open google maps in browser with following parameters:-
http://maps.google.com/maps?z=12&t=m&q=<lat>,<lng>
z is the zoom level (1-21)
t is the map type ("m" map, "k" satellite, "h" hybrid, "p" terrain, "e" GoogleEarth)
q is the search query
Using the query parameter won't work, Google will try to approximate the location.
The location I want : http://maps.google.com/maps?ll=43.7920533400153,6.37761393942265
The approximate location (west of the actual location) : http://maps.google.com/?q=43.7920533400153,6.37761393942265
say easily http://www.google.com/maps/place/lat,lng format
sample url:
http://www.google.com/maps/place/30.364124,48.227034
To get your current location as start point you need to use this URL:
https://www.google.com/maps/dir/?api=1&origin=Current+Location&destination=<latitude>,<longitude>
You can fill up the destination parameter with the address, name or latitude and longitude values.
Open the following url with the latitude and longitude and zoom level.
https://maps.google.com/?q=23.22,88.32&z=8
Find your location in the Google Earth program, and click the icon "View in Google Maps". The URL bar in your browser will show the URL you need.
Open google map and show URL schemes location and location pin
UIApplication.shared.openURL(URL(string:"https://maps.google.com/?q=\(dicLocation.stringValueForKey("latitude")),\(dicLocation.stringValueForKey("longitude")),15z")!)
if you want a dir with travel mode = walking
https://www.google.es/maps/dir/'52.51758801683297,13.397978515625027'/'52.49083837044266,13.369826049804715'/data=!4m2!4m1!3e2
Well i want to upgrade contact page with dynamic map showing location and give oportunity to calculate route for comapny headquatters. Id it necessery for such simple task use Google api? i mean here generating akey etc? Fo i have any other alternatives to google maps?
There's really no reason to mess with the API at all unless you need to customize the appearance or behavior of gmaps. Why not just use an iframe with a url of:
http://maps.google.com/?q=[you-url-encoded-address-here]
or better yet, set up a textbox and a 'get directions' button to redirect that frame to:
http://maps.google.com/maps?saddr=[their-address]&daddr=[your-address]
edit: this works well in modal dialog if you don't want the google logo sticking out like a sore thumb in your pageflow
You could probably embed directly with a specific URL that will configure it to have the destination you want.
By the way, well written answers are much more likely to receive useful responses here.
You could consider http://www.openlayers.org/ as an alternative to google maps.
In fact open layers can be used to add a Google map, or an OpenStreetMap map or a Bing map, etc.