检查纬度和经度的公式是在没有Google Maps Api的区域内

I have this Example Map:

enter image description here

I make Boundary Polygon shape,

-6.875165174925262, 107.56293296813965
-6.882663904407988, 107.66730308532715
-6.980818117491586, 107.67210960388184
-6.97093546084682, 107.54508018493652

How can I check if the given (Lat, Lng) -6.935884,107.611592 is inside that Boundary Polygon?

I need to do it without Google Maps API, because the program will be offline and must check more often than Google API's free service will allow.

Is there any geometric formula I can use for this? With PHP or Python if possible.

Finally i got the answer ... Detect Point in Polygon

this function help me alot ... and works great... others function sometime give false result whether point in or outside polygon

I'm not a javascript guy but, seems like a plane geometry from the schools, let say you have polygon with corners

A(x1, y1), B(x2, y2), C(x3, y3), D(x4, y4)

enter image description here

and if you want to check if a point E(X,Y) resides on the area of polygon you can do it like this

  1. Construct the equations of each line AB, BC, CD, DA like this y - y1 = m(x - x1) where m=(x1-x2)/(y1 - y2) where A(x1, y1) and B(x1, y2)

  2. Check if the point E(X, Y) resides on the corresponding side of the line like this

if (Y > m(X - x1) + y1)
{
   // resides on the upper area
}
else (Y < m(X - x1) + y1)
{
   // resides on the below area
}
else
{
   // resides right on the line
}

You can try to use this PHP library (https://github.com/xopbatgh/sb-polygon-pointer) for you case.

All you need to do is:

  1. Insert the coordinates of your polygon

  2. Ask the library is the any point with lat/lng inside this polygon

$polygonBox = [
    [55.761515, 37.600375],
    [55.759428, 37.651156],
    [55.737112, 37.649566],
    [55.737649, 37.597301],
];

$sbPolygonEngine = new sbPolygonEngine($polygonBox);

$isCrosses = $sbPolygonEngine->isCrossesWith(55.746768, 37.625605);

// $isCrosses is boolean