-1

How to call the isLocationOnEdge function from .Net Core on server side?

Something like this,

var api= "https://maps.googleapis.com/maps/api/directions/json?origin=" + originLat + ',' + originLng + "&destination=" + destinationLat + ',' + destinationLng + "&key=" + apiKey;

Whether the isLocationOnEdge function could also be called like calling the direction API, is there any way to do that?

Kezia Rose
  • 365
  • 1
  • 2
  • 12
  • 1
    The geometry library is part of the Maps Javascript API. – MrUpsidown Mar 23 '20 at 12:40
  • I need to call it in c# code without using Javascript. And the geometry library is not supported in .Net Core – Kezia Rose Mar 23 '20 at 14:43
  • 1
    Well that's what I said. It **is** part of the Javascript API. There is no web service. – MrUpsidown Mar 23 '20 at 14:55
  • I wanted to know if there is any way to call the function as mentioned in the question? If not, if there is any alternative to do that? – Kezia Rose Mar 24 '20 at 05:16
  • I don't know how else I should say the exact same thing again. The **geometry library** is part of the **Javascript API** and there is **no web service** to access it so if you need to use these methods, you need to do it through the **Javascript API**. That was my last comment here... – MrUpsidown Mar 24 '20 at 11:12

1 Answers1

0

I've found an alternative method to get it work from here

public bool isLocationOnEdge(List<Location> path, Location point, int tolerance = 2)
    {
        var C = new GeoCoordinate(point.Lat, point.Lng);
        for (int i = 0; i < path.Count - 1; i++)
        {
            var A = new GeoCoordinate(path[i].Lat, path[i].Lng);
            var B = new GeoCoordinate(path[i + 1].Lat, path[i + 1].Lng);
            if (Math.Round(A.GetDistanceTo(C) + B.GetDistanceTo(C), tolerance) == Math.Round(A.GetDistanceTo(B), tolerance))
            {
                return true;
            }
        }
        return false;
    }
Kezia Rose
  • 365
  • 1
  • 2
  • 12