I am trying to get the distance between 2 points using the Longitude and Latitude in c# now i stumbled into some good codes and using them in my code i am getting this as an exception error :
System.Net.WebException: 'Request Not Authorized or Over QueryLimit'
My code is looking thus :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GoogleMaps.LocationServices;
using System.Device.Location;
namespace DistanceCalcConsole
{
class Program
{
static void Main(string[] args)
{
getDistancebetween2Points();
}
private static void getDistancebetween2Points()
{
var originAddress = "Lagos, Nigeria";
var locationService = new GoogleLocationService();
var point = locationService.GetLatLongFromAddress(originAddress);
var latitude1 = point.Latitude;
var longitude1 = point.Longitude;
var destinationAddress = "Ibadan, Nigeria";
var locationService2 = new GoogleLocationService();
var point2 = locationService2.GetLatLongFromAddress(destinationAddress);
var latitude2 = point.Latitude;
var longitude2 = point.Longitude;
var locA = new GeoCoordinate(latitude1, longitude1);
var locB = new GeoCoordinate(latitude2, longitude2);
double distance = locA.GetDistanceTo(locB);
double finalDistance = distance / 1000;
Console.Write(finalDistance +" Kilometers");
Console.Read();
}
}
}
Does it look like i am missing something? was made to understand that using Googlemaps.Locationservice is free so i should not be expecting this error...