Link to street view URL using address? - google-maps

Is it possible to link directly to street view from an URL using only the address (and not lat/lng)?
For example, is there a way to do something like
http://maps.google.com/maps?q=&layer=c&address=Street,number,state&cbp=11,0,0,0,0
Instead of
http://maps.google.com/maps?q=&layer=c&cbll=31.335198,-89.287204&cbp=11,0,0,0,0
?
Lat/lng from geocoding tends to not be recognized by street view as being too far from a street, sometimes getting the wrong street altogether, because the lat/lng it generates may be off the street, as it tries to match the location of a house.
I have looked everywhere and even tried playing with google's URLs on my own, but I can't find anything on it. Most sources won't even mention address. I'm currently using the url sample from this question, but it still isn't really what I'm looking for.
If this is really not possible, could someone link to a source/documentation where it says so?
Edit: Thank you everyone for the answers, but none really address the issue with street view and addresses. I'll look into forwarding this to google. I'll post here if I get a reply.

Let's enhance your code, if you paste the code in browser then you will be redirect to google maps and will show result what you requested.
http://maps.google.com/maps?&q=Space+Needle,Seattle+WA
If you would like to pass the value (address) via php or any other code type then simply it will not work, you cannot use google maps without API to enhance your requirement. Lat & Lng is basic practice to show map and not require any api, but if you would like to pass additional properties then you will have to use google maps api to do so. Detailed documentation can be found here
https://developers.google.com/maps/documentation/embed/guide
but let's try an example try this code in browser
https://www.google.com/maps/embed/v1/place?q=Mumbai,+Maharashtra,+India
You will get an error that api key not found but if you try this one
https://www.google.com/maps/embed/v1/place?key=AIzaSyD4iE2xVSpkLLOXoyqT-RuPwURN3ddScAI&q=Space+Needle,Seattle+WA
Then you will get output. Hope it helps!

First reverse geocode to find the lat lng using another Google Service API.
Then feed the resulting lat lng into the streetview endpoint parameter.

Related

Google Maps - Show address instead geocodes

I have link with geo-coordinates (below), when I reach by this URL to the google maps page, in Input I see my geo-coordinates.
Is it possible to get their Human-readable Address instead of geocodes, without changing URL format (should be used geo-coordinates) ?
https://www.google.com/maps?&z=16&q=51.5362671,-0.11687110000002576&ll=51.5362671,-0.11687110000002576
If I understood question correctly, you need to use Reverse Geocoding. I found some links. It aren't solutions of your problem but (I hope) these examples help you to find solution.
Reverse Geocoding. This page has input where you can put coordinates and check the address. I put coordinates 51.5362671,-0.11687110000002576 and get result: Carnegie Street (Stop L), London N1, Великобританія. From code you can find how to get formatted address.
Geocoding Service. Read about Geocoding Responses: formatted_address field and Reverse Geocoding (Address Lookup). This doc also has examples how to get formatted address.
Perhaps, this link also can help you:
Reverse Geocoding: Get address from Latitude and Longitude using Google Maps Geocoding API
If you get formatted address you can use jQuery .val() method to set value for input:
var address = ... // code to get formatted address
$("selector_for_input").val(address);
Here you can find example of using .val() method.
I know that these links aren't 100% solutions of your problem but I hope you can find there answer for your question.

Google maps - url with lat & lon returns "We could not find *lat*, *lon*"

I have website that creates url with lat and lon values like this:
http://maps.google.com/maps?q=45.50459,-73.56363
This has worked as expected for couple of years eg returns Google Map with pin on the location of the lat and lon, but recently I am occasionally getting the following result:
We could not find 45.52705,-73.61622
Make sure your search is spelled correctly. Try adding a city, state, or zip code.
The Google Map page screenshot with this result is below.
If I put my cursor into search box and hit enter with the lat and lon, it successfully returns expected results eg map with pin on lat and lon.
This appears to be occasional and random. A url with specific lat and lon may work, but then when tried a second time, it returns the results below.
Any ideas what is happening here?
To be clear I am not looking for alternate url solutions, but am looking for insight into why my url solution, which does work, but occasionally and randomly returns the "We could not find lat, lon" page. As far as I can tell, my url solution is acceptable.
Is this a Google time out or some other rate limiting effect?
Google limits the use of their APIs. That alone can account for what you perceive as inconsistent behavior. Add in that they use multiple datacenters to load balance that might have different sensitivities to enforce limits and you're out of luck to figure it all out yourself.
The solution is to follow the "rules".
You need to apply for an API key and based on usage you might even have to send them money to do this reverse geocoding.
References:
https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding
https://developers.google.com/maps/documentation/geocoding/get-api-key
https://developers.google.com/maps/documentation/geocoding/usage-limits
Google Maps (http://maps.google.com) has changed. They changed their URL query scheme. It wasn't documented (by them at least). If you want a consistent result, one option would be to use the Embed API.

How do I get a direct link to a place on google maps with the Place Id

I have the Place Id of a place on google maps in my app. Is there a way to put the place Id in a URL and have it directly link to the page? Or does it have to be done through the URL?
I can't seem to find anything detailing this in the docs. I've tried below, but it just gets me the standard google maps page:
https://maps.google.com/maps?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4
Recently, in May 2017, Google launched the new Google Maps URLs API. You can read about this API in the official documentation
https://developers.google.com/maps/documentation/urls/guide
So, from now on you can construct a URL for Google Maps using the place ID. In your particular case this URL will be
https://www.google.com/maps/search/?api=1&query=Google&query_place_id=ChIJN1t_tDeuEmsRUsoyG83frY4
Hope this helps!
Not directly, using the placeID you can get a variety of information in JSON or XML format, among them there are also the lat lng of the place and its address with which you can easily locate the map
google developer doc
The URL for a specific Google Place is returned by the places details API endpoint.
If for example you query:
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJV2BQ4laeekgRFauLvdXbFXE&key=YOUR_API_KEY
You will see that in the returned JSON there is a key 'url' which points to https://maps.google.com/?cid=8148660811851344661
The correct format, at this time, to produce a general link that goes directly to correct google place is: https://maps.google.com/?cid=[place_id]&t=[maptype]
The map type parameter "t" is apparently necessary. Without it, google maps seems to perform a more general search when the link opens that is sometimes successful and sometimes not. With it, maps opens to correct place each time whether it opens in browser or in app on mobile.
Set this parameter to "m" for a street map and "k" for a satellite map.
A lot of answers on SO show the following syntax which often pulls unwanted results if two locations of the same name are nearby e.g.:
https://www.google.com/maps/place/Starbucks/#43.088554,-88.06579,17z/
If you are already using google places api, then you have the place_id, so i recommend using it to avoid ambiguity.

google maps api geocoding is less precise than manual search, why?

i am using a php script (followed this tutorial http://www.bitconsultants.net/2010/geocoding-with-google-maps-and-the-zend-framework/) to get the latitude and longitude of different adresses,
the problem is that if i manually search an address in google maps it gives me the right location,
while using the php script, the json response from google is even 500meters away from the manual search result, which makes it kind of pointless for my needs...
i am passing the address in this format
$address = "{$data['street']}, {$data['postcode']}, {$data['city']}, {$data['province']}";
and i am passing google a key
thank you
Are your addresses really well formed? Could you please give a concrete example?
Such difference could occur if the postal address is not found at given city or town and Google tries to partially match the given address. See *partial_match* on API documentation.
Also: unfortunately the link you gave above does not work here ("Forbidden" error).
i found out why, don't use php urlencode() on the $address, it does something strange with "," and maybe other stuff, so google doesn't understands well your url

Google maps API - how to include marker (and info) for specific business address?

All the methods and examples I can find about the Google maps api is based on a postcode, or coordinates to get the desired location - what if I want to place a marker for a specific business which has been added to google maps, so it shows tel number etc like an embeded map would? Even if I use exact coordinates for the address it doesn't recognise it. Sure I'm missing something really simple here...
Thanks!
The Google Places API, this does what your looking for. I couldn't tell you how to implement as of now because i am trying to put it inside of my Rails application but i will update my answer in the future when i do get it working though.