You are on page 1of 2

GPS Example

1. Add the reference of


http://dev.virtualearth.net/webservices/v1/metadata/geocodeservice/geocodeservic
e.wsdl
2. Button click code
ServiceReference1.GeocodeServiceClient client = new
ServiceReference1.GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
ServiceReference1.ReverseGeocodeRequest req = new
ServiceReference1.ReverseGeocodeRequest();
req.Credentials = new ServiceReference1.Credentials();
req.Credentials.ApplicationId = "AtaeM1towemiWqFlsotLXG9DP9v2JFzOQQHxe9XBnhLoD31NkpovUP1aAGm1lso";
ServiceReference1.Location loc = new ServiceReference1.Location();
loc.Longitude = Convert.ToDouble(txt_long.Text);
loc.Latitude = Convert.ToDouble(txt_lati.Text);
req.Location = loc;
client.ReverseGeocodeCompleted += new
EventHandler<ServiceReference1.ReverseGeocodeCompletedEventArgs>(client_ReverseGeocode
Completed);
client.ReverseGeocodeAsync(req);

3. Event Code
void client_ReverseGeocodeCompleted(object sender,
ServiceReference1.ReverseGeocodeCompletedEventArgs e)
{
del oo = delegate
{
txtaddress.Text += e.Result.Results[0].Address.FormattedAddress;
txtaddress.Text += e.Result.Results[0].Address.CountryRegion;
txtaddress.Text += e.Result.Results[0].Address.PostalCode + " " +
e.Result.Results[0].Address.Locality;
};
this.Dispatcher.BeginInvoke(oo);
}

4. Enter these latitude and longitude


Lat : 18.5224
Long : 73.8486

Lat : 18.553658
Long : 73.806892

You might also like