Good Afternoon to all,
I am really hope someone can help. I built a simple test form and use
this code on the backend to access the API. Even if I type in really
goofey stuff it comes back with countries and such. I am trying to
verify addresses for the purpose of qualifing if a bus can deveiate
from it's route to get them. even if I enter for the zip code
1234726253 and a city of tyehdt it returns France or something. What
am I doing wrong? Any help would be greatly appreciated ;)
Code I wrote
XmlReaderSettings settings = new XmlReaderSettings();
bool bLoop = true;
string strStatus = "";
settings.IgnoreWhitespace = true;
settings.IgnoreComments = true;
HttpWebRequest request =
(HttpWebRequest)WebRequest.Create(String.Format("http://
maps.googleapis.com/maps/api/geocode/xml?address={0},{1},{2}
&sensor=false", txtStreet.Text, txtCity.Text, txtState.Text)) as
HttpWebRequest;
request.Timeout = 500;
using (HttpWebResponse response =
(HttpWebResponse)request.GetResponse())
using (XmlReader reader =
XmlReader.Create(response.GetResponseStream(),settings))
{
while (reader.Read() && bLoop)
{
if (reader.NodeType == XmlNodeType.Element &&
reader.Name == "status")
{
strStatus = reader.ReadString();
if (strStatus.ToUpper() != "OK")
{
txtAnswer.Text = "Nothing Found";
bLoop = false;
}
}
if (reader.NodeType == XmlNodeType.Element &&
reader.Name == "result")
{
reader.ReadToDescendant("formatted_address");
string strWhatIsThis= reader.ReadString();
reader.ReadToFollowing("geometry");
reader.ReadToDescendant("lat");
string strlat = reader.ReadString();
reader.ReadToNextSibling("lng");
string strlng = reader.ReadString();
txtAnswer.Text += string.Format("Lat: {0},
Lng: {1} ", strlat, strlng);
bLoop = false;
}
}
reader.Close();
response.Close();
}
}
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.