Address validation via Google Maps API - google-maps

I want to send an address via Google API and get a response if this is a valid or wrong address. If it's a wrong address the response will include the reason (e.g. wrong zip code, wrong state etc.)
Is it possible?
Thanks

Google Maps APIs are not intended for address validation. They do, however, provide a variety of other services including geolocation, directions, distance calculation, and much more. For a list of APIs as well as what they can do for you please check out the API Picker here:
https://developers.google.com/maps/documentation/api-picker
I hope this helps!

Related

Link to street view URL using address?

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.

Wanted to use Google Map API in desktop client

I want to use th Google Map API for my desktop tool.As I dont want to show any Map control in the UI I just want to give some address to API and the google should return me the city,country,zip etc.
Please tell me how I can achieve this.
You can't use the Google Maps API in a situation where you're not going to display a map. From the documentation:
Note: the Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited. For complete details on allowed usage, consult the Maps API Terms of Service License Restrictions.
I suspect you'll need to look for other commercial solutions for your situation.
Note that although I work for Google, this post is not made on behalf of Google - it's just based on the public documentation.

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 - Get Coordinates of address

I would like to convert addresses into long/lat.
Is there any way to do this without using JavaScript? Because in my case there is no need to display anything since the conversion is in the background.
What you are looking for is called Geocoding.
Google provides a Geocoding Web Service which should do what you're looking for. You will be able to do geocoding on your server.
JSON Example:
http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA
XML Example:
http://maps.google.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA
Edit:
Please note that this is now a deprecated method and you must provide your own Google API key to access this data.
Althugh you asked for Google Maps API, I suggest an open source, working, legal, free and crowdsourced API by Open street maps
https://nominatim.openstreetmap.org/search?q=Mumbai&format=json
Here is the API documentation for reference.
Edit: It looks like there are discrepancies occasionally, at least in terms of postal codes, when compared to the Google Maps API, and the latter seems to be more accurate. This was the case when validating addresses in Canada with the Canada Post search service, however, it might be true for other countries too.
Geocoding through Javascript:
https://developers.google.com/maps/documentation/javascript/geocoding
A Nuget solved my problem:Geocoding.Google 4.0.0.
Install it so not necessary to write extra classes etc.
https://www.nuget.org/packages/Geocoding.Google/

Is it possible to get Google Maps Directions using HTTP requests?

Is it possible to use the Google Maps API router just using HTTP? Something like http://maps.google.com?from=blah?to=blah
And have it return some sort of XML or JSON representing the directions?
If you want Google to allow legal access to driving directions via HTTP you might consider voting for the enhancement request: Issue 235. Theoretically, the more people that vote for an enhancement request, the more attention Google give to it.
However, I strongly suspect that there might be contractual issues with the organisations that supply the data. Organisations like TeleAtlas impose restrictions about how Google can use their data. TeleAtlas probably don't want Google to make it legal for people to use their data to create apps for free that directly compete with their own commercial apps and devices.
There is no documented and approved method to access driving directions via an HTTP API request.
This makes it difficult to get driving directions on the server-side, which I assume is your intention.
Not only it is undocumented and difficult to achieve, but it would also violate the restrictions 10.1 and 10.5 of the Google Maps API Terms and Conditions.
However, if you don't mind the challenge, and you believe that rules are there to be broken, you may want to check these articles:
Calculate driving directions using PHP?
Retrieve driving directions from google maps with server-side HTTP calls and show results with static maps for WAP
Actually yes, and they do it themselves
The REST format is like:
http://maps.google.com/maps/nav?output=js&q=from:%20Montreal%20to:%20Toronto&key=apikey
Where q should have the form: "from: x to: y" (url encoded).
Some of the parameters are similar to the HTTP Geocoding service: http://code.google.com/apis/maps/documentation/geocoding/index.html
Mike
As of May, 2010, directions are available via web services:
http://code.google.com/apis/maps/documentation/directions/
Directions are returned in XML or JSON format:
http://maps.google.com/maps/api/directions/json?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false
http://maps.google.com/maps/api/directions/xml?origin=Boston,MA&destination=Concord,MA&waypoints=Charlestown,MA|Lexington,MA&sensor=false
It's pretty danged easy to use.
Here you can find a list of parameters you can pass to the maps.google.com URL. Maybe you'll be able to get the information you need. I don't know what the returned output contains. At least you are able to define different output types.
I have already used this library with python and it works well, although it's against Google Maps API Terms.
API v3 (made the official version in the last six months), does:
http://code.google.com/apis/maps/documentation/directions/
Also note that most of the competing services (Bing Maps, Yahoo, MapQuest, CloudMade, etc) also support RESTful web services along these lines.
As always with these services, check the Terms & Conditions.
I've never used the API but it is pretty easy to get the structured directions data from a google maps page using JS to access the gmap page's DOM.