Geocoding.net
Geocoding.net copied to clipboard
The Longitude Value does change when you get more then one GoogleGeocode.
The Longitude Value does change when you get more then one GoogleGeocode at a time.
Could you provide some more detail of what you are sending and receiving and how the data differs from what you expect?
I am just sending 2 address in Australia
foreach (string destination_address in destination_addresses) { IGeocoder geocoder = new GoogleGeocoder() { ApiKey = "xxxxxx" };
IEnumerable<Address> address = geocoder.Geocode(destination_address);
if (address.Count() != 0)
{
addresses.Add(address.First());
Console.WriteLine("Formatted: " + address.First().FormattedAddress);
Console.WriteLine("Coordinates: " + address.First().Coordinates.Latitude + ", " + addresses.First().Coordinates.Longitude);
//Console.ReadKey();
}
geocoder = null;
address = null;
}
@georgioua You enumerate the IEnumerable 4 times in your loop. Thus, you call the Geocode function 4 times. I suppose you get more than one result and the result from System.Linq.First() delivers the other result on your second query, wether it is because Google returned them in another order or the Geocode function does something with the order.
Please provide the console output from this code: (change ApiKey & destinationAddress)
using (IGeocoder geocoder = new GoogleGeocoder() { ApiKey = "xxxxxx" }){
string destinationAddress = "###";
Console.WriteLine("Query string: ", destinationAddress);
for (int i=0; i<2; i++){
Console.WriteLine("========");
Console.WriteLine("Query #: ", i);
Address[] address = geocoder.Geocode(destinationAddress).ToArray();
for (int j=0; j < address.Length; j++){
Console.WriteLine("Result #: " + j);
Address a = address[j];
Console.WriteLine("Formatted: " + a.FormattedAddress);
Console.WriteLine("Coordinates: " + a.Coordinates.Latitude + ", " + a.Coordinates.Longitude);
}
}
}