: , api .
REST API (XML/JSON/CSV).
http://maps.google.com/maps/geo?q=State+St,+Troy,+NY&output=csv&oe=utf8&sensor=false
:
200,6,42.730070,-73.690570
:
- 200 - G_GEO_SUCCESS
- 6 -
- 42.730070 -
- -73.690570 -
API System.Net, :
const string GeoCodeUrlFormat = "http://maps.google.com/maps/geo?q={0}&output=csv&oe=utf8&sensor=false";
string location = "State St, Troy, NY";
string url = String.Format(GeoCodeUrlFormat, HttpUtility.UrlEncode(location));
HttpRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
HttpResponse response = (HttpResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
using (StreamReader reader = new StreamReader(responseStream)
{
string firstLine = reader.ReadLine();
string[] lineParts = firstLine.Split();
GeolocationResult result = GoogleMapper.MapGeolocationResult(lineParts);
}
, , , MapGeolocationResult, .