I am working in c#.Net. My requirement is to get the latitude and longitude from the api, based on the address,city,state and zip which had given as a parameter.
I am having 350 stores details in a excel sheet. Initially i had used google api.
if (strAdd != "" && strCity != "" && strState != "" && strZip != "" && strStoreNo != "")
{
Address = strAdd.Trim() + "," + strCity.Trim() + "," + strState.Trim() + "," + strZip.Trim();
string routeReqUrl = "http://maps.google.com/maps/geo?q={0}&output=xml&oe=utf8&sensor=true_or_false&key={1}";
string url = string.Format(routeReqUrl, Address.Replace(' ', '+'), "ABQIAAAA5rV-auhZekuhPKBTkuTC3hSAmVUytQSqQDODadyYeWY4ZYaVyRRv4thyrzzOQ7AMUl_hIjoG8LomGA");
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "GET";
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream respStream = resp.GetResponseStream();
XmlDocument xDoc = new XmlDocument();
xDoc.Load(respStream);
if (xDoc.GetElementsByTagName("coordinates")[0].InnerText.Contains(","))
{
string[] coordinates = xDoc.GetElementsByTagName("coordinates")[0].InnerText.Split(',');
string Latitude = coordinates[1];
string Longtitude = coordinates[0];
Logger.Log.Debug("[Latitude and Longitude] " + " Store - No " + strStoreNo + " Addr Line 1 " + strAdd + " Latitude " + Latitude + " Longitude " + Longtitude);
}
}
In the above code, only around for 10 to 15 stores i can able to get the latitude and longitude details. After that i am getting the object reference error in "(xDoc.GetElementsByTagName("coordinates")[0].......".
After that i had tried with yahoo api, i am using the same excel sheet which had 350 stores.
dsxml.ReadXml("http://where.yahooapis.com/geocode?appid=capelinks&location=" + Address + "&Geocode=Geocode");
if (dsxml.Tables[0].Rows.Count > 0)
{
if (dsxml.Tables[1].TableName == "Result")
{
string Latitude = dsxml.Tables[1].Rows[0]["Latitude"].ToString();
string Longtitude = dsxml.Tables[1].Rows[0]["Longitude"].ToString();
Logger.Log.Debug("[Latitude and Longitude] " + " Store - No " + strStoreNo + " Addr Line 1 " + strAdd + " Latitude " + Latitude + " Longitude " + Longtitude);
}
}
Here, its process all the 350 stores correctly without any error.
What will be the issue with google api. whether there are any restrictions for taking the latitude and longitude details for large number of stores.