Google Maps API - Get Coordinates of address - google-maps

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/

Related

Address validation via Google Maps API

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!

Google Maps API V3 Store Locator

I'm trying to create a store locator for my work. I've seen this done before using Google Maps API V2, but have not seen a good example using V3.
Here's a mockup of what I'm aiming to get working: http://imgur.com/eKMwo
I think it's a pretty simple concept, but what I'm having trouble getting to work is the parts pertaining to the stores themselves.
Does anyone know of any examples, tutorials or demos of something similar to the image linked above?
Edit: This related question may help you debug when making a store locator: Google Maps API - geocode() doesn't return lat and long
The V3 API for a store locator is horrible!
I used this and many functions weren't defined.
Everything was going fine for me until I got to the XML parsing, then Google's API started breaking on me. Absolutely deplorable, IMHO.
Actually, there is a V3 version of this article.
http://code.google.com/apis/maps/articles/phpsqlsearch_v3.html
I followed this documentation for creating a store locator: http://storelocator.googlecode.com/git/index.html
I used the Google Code one (maybe that's the one you already saw)..
http://code.google.com/intl/sv-SE/apis/maps/articles/phpsqlsearch.html
Granted it's for API V2 but its actually very easy updating it to API V3.. Just have look at he API V3 reference when in doubt..
http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html
I use this this API as it makes it real simple, can do a store locator in couple of hours
http://www.ehoundplatform.com/developers/documentation-developers/store-locator-using-freehound-and-google-maps-v-3

Using C++ with Google Maps API. Only text info required

Is it possible to call Google Maps API using a C++ code to retrieve text info about nearby locations.
I am trying to make a simple application (C++) which gives the information about Nearby places on entering longitude and latitude info. Only data I am looking for is the Name of Nearby place and its distance from mentioned location.
Is it possible?
I think your best option would be to use the Google Places API with the JSON format for request.
I don't know about any library that would perform the thing automatically, but there is a thread on StackOverflow about JSON parsing in C++ . Even it does not provide an answer it as good votes scores.
I guess the web call could be made with something like curl.

Google geocoding inaccuracy (in Israel)

I'm trying to use Google Geocoding API, but i keep on getting a very inaccurate answer (off by 3.2 KM).
Here is an example:
http://maps.google.com/maps/api/geocode/json?sensor=true&address=Hava%27ad+Haleumi+21+Jerusalem
I get the coordinate 31.7857,35.2007.
Ff you look up "Hava'ad Haleumi 21 Jerusalem" in maps.google.com, you can see that the location is 3.2KM away from what Google Geocoding API gave me.
Does anyone know why this happens?
Thank you.
Actually, the Google Maps API does not support geocoding in Israel beyond city level, so your solution is to do what you did and finding an alternate geocoding service.
The reason you got the correct location when searching on maps.google.com is because the API uses a different provider than maps.google.com due to licensing issues.
Here is a spreadsheet detailing the coverage area for Google Maps.
It's possible to use waze.co.il instead of google:
Their JSON API is
http://www.waze.co.il/WAS/mozi?q=yourAddress&token=yourToken
(Also, as stated in this thread http://www.waze.co.il/forum/viewtopic.php?f=21&t=6113
reverse geocoding is a paid service.)
Take a look at the response. You are getting a partial match and the location type is approximate. If you look at the veiwport you will probably find that the location you are looking for falls within that viewport. *Edit - Actually it looks like it just matched to city - Jersulem in this case - which is why you are probably off by so far

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.