Skip to content

Instantly share code, notes, and snippets.

@kianryan
Last active December 22, 2015 21:59
Show Gist options
  • Save kianryan/6536734 to your computer and use it in GitHub Desktop.
Save kianryan/6536734 to your computer and use it in GitHub Desktop.
Google Geocoding Example API v3
public void GoogleGeoCode(string address, out double lat, out double lon)
{
string url = "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=" + address;
var req = (HttpWebRequest)WebRequest.Create(url);
var reader = new StreamReader(req.GetResponse().GetResponseStream());
var body = reader.ReadToEnd();
lat = double.Parse(Regex.Match(body, @"""lat\"" : ([\d\.]+)").Groups[1].Value);
lon = double.Parse(Regex.Match(body, @"""lon"" : ([\d\.]+)").Groups[1].Value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment