GetRoute() not working, GetDirections giving REQUEST_DENIED (HTTPS needed??)
As i read GetRoute() has been depreciated by google so i think you can remove it from GMAP. Moroever i though using GetDirections() instead could be the solution. Unfortunately, it looks like this, but it's just my guess that GetDirections uses HTTP instead of HTTPS so even with the correct API key you get REQUEST_DENIED. I saw that this has been fixed for NET Core. Is there a chance to do this for WIndows Forms?
This code proves that:
Res variable gets = REQUEST_DENIED.
var gprovider = GMapProviders.GoogleMap;
gprovider.ApiKey = "correct API key";
gMapControl2.MapProvider = gprovider;
GDirections routedir = null;
DirectionsStatusCode Res = gMapControl2.DirectionsProvider.GetDirections(out routedir, gMapControl2.Position, new PointLatLng(54.7261334816182, 25.2985095977783), false, false, false, false, true);
if (Res == DirectionsStatusCode.OK)
{
//Code Here - not reached !!
}
GMapRoute tablemaproute = new GMapRoute(routedir.Route, "Ruta ubication");
GMapOverlay tablerouteoverlay = new GMapOverlay("Capa de la ruta");
tablerouteoverlay.Routes.Add(tablemaproute);
gMapControl2.Overlays.Add(tablerouteoverlay);
gMapControl2.Zoom = gMapControl1.Zoom + 1;
gMapControl2.Zoom = gMapControl1.Zoom - 1;
double distance = tablemaproute.Distance;
MessageBox.Show(distance.ToString());
"I saw that this has been fixed for NET Core" What do you mean? Where was it fixed?
Windows Forms is not a pair of .NET Core... Windows Forms exists in .NET Framework and in .NET Core, too.
DirectionsStatusCode route; GMapRoute routes; Random rnd = new Random();
route = GMapProviders.GoogleMap.GetDirections(out GDirections direction, lat_log_ant, lat_log_act, false, false, false, false, false);
if (route == DirectionsStatusCode.OK) { routes = new GMapRoute(direction.Route, "routes"); routes.Stroke = new Pen(Color.FromArgb(160, Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256)))); routes.Stroke.Width = 5; routes.Stroke.StartCap = LineCap.RoundAnchor; routes.Stroke.EndCap = LineCap.ArrowAnchor; routes.Stroke.CustomEndCap = new AdjustableArrowCap(3, 3); routes.Stroke.DashStyle = DashStyle.Solid;
RoutesOverlay.Routes.Add(routes);
}
Is it resolved by any code ?