Using System;
Using System. Collections. Generic;
Using System. text;
Using System. net;
Using System. IO;
Namespace Yournamespace
{
/// <Summary>
/// A class for latitude and longtitude
/// </Summary>
[Serializable]
Public Class GEO
{
/// <Summary>
/// Latitude
/// </Summary>
Private String _ Latitude = "" ;
/// <Summary>
/// Longtitude
/// </Summary>
Private String _ Longtitude = "" ;
/// <Summary>
///Default constructor
/// </Summary>
PublicGEO ()
{
}
/// <Summary>
/// Construct GEO given latitude and longtitude
/// </Summary>
/// <Param name = "latitude"> </param>
/// <Param name = "longtitude"> </param>
Public GEO ( String Latitude, String Longtitude)
{
_ Latitude = Latitude;
_ Longtitude = Longtitude;
}
/// <Summary>
/// Construct GEO given name of a place
/// </Summary>
/// <Param name = "location"> </param>
Public GEO ( String Location)
{
String Output = " CSV " ;
String URL = String . Format ( " Http://maps.google.com/maps/geo? Q = {0} & Output = {1} " , Location, output );
Httpwebrequest request = (Httpwebrequest) webrequest. Create (URL );
Httpwebresponse response = (Httpwebresponse) request. getresponse ();
Using (Streamreader SR = New Streamreader (response. getresponsestream ()))
{
String [] Tmparray = Sr. readtoend (). Split ( ' , ' );
_ Latitude = Tmparray [ 2 ];
_ Longtitude = Tmparray [ 3 ];
}
}
/// <Summary>
/// Get latitude)
/// </Summary>
Public String Latitude
{
Get { Return _ Latitude ;}
Set {_ Latitude = Value ;}
}
/// <Summary>
/// Get longtitude (longitude)
/// </Summary>
Public String Longtitude
{
Get { Return _ Longtitude ;}
Set {_ Longtitude = Value ;}
}
}
}
Call method: Geo g = New GEO ( " Place Name " );