geocoder.us / geocoder.net

find the latitude & longitude of any US address - for free

Client Documentation

Updated 04 December 2005

Getting around the msXML issue

Geocoder.us user Jeremy Walker kindly sent in this bit of code that gets around the credential issue. This is a solution in C# (.Net) But Jermemy is sure that other strongly typed languages have similar network credential & WebRequest objects.

// Create a request using the geoCoder URL
WebRequest request = WebRequest.Create("http://geocoder.us/member/service/csv/geocode");

//Create Credentials object
NetworkCredential creds = new NetworkCredential("username","password");
CredentialCache cCache = new CredentialCache();

//Add the URI to the credential cache
cCache.Add(new Uri("http://geocoder.us/member/service/csv/geocode"), "Basic", creds);
request.Credentials = cCache;

// Get the response.
WebResponse response = request.GetResponse ();

// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream ();

// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader (dataStream);
                       
// Read the content.
string[] responseFromServer = reader.ReadToEnd ().Split(',');

if(responseFromServer.Length != 6)
return;
                       
longitude = responseFromServer[1];
latitude = responseFromServer[0];
******************************