Since you tagged the question with Google I presume you would want to use the Google Geocoding API service? The documenation there pretty much explains how to use it - you pass the address as a query-string parameter to the service (via simple REST like URL) and you can get back either XML or JSON. An example of an XML query:
http://maps.googleapis.com/maps/api/geocode/xml?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=false
As part of the XML response you will see the lat/long:
<location>
<lat>
37.4213068
</lat>
<lng>
-122.0852900
</lng>
</location>
Just remember to set the sensor
parameter to either true
or false
as this is required.
Note the v3 API doesn't require an API key but does have some usage limitations you should be aware of, including:
- a query limit of 2,500 geolocation requests per day.
- the Geocoding API may only be used in conjunction with a Google map; geocoding results without displaying them on a map is prohibited