// 判断当前经纬度是否在规定区域内
function pointInPolygon(point : any, polygon : any) {
const x = point[0];
const y = point[1];
let inside = false;
for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
const xi = polygon[i][0], yi = polygon[i][1];
const xj = polygon[j][0], yj = polygon[j][1];
const intersect = ((yi > y) !== (yj > y)) &&
(x < ((xj - xi) * (y - yi)) / (yj - yi) + xi);
if (intersect) {
inside = !inside;
}
}
return inside;
}
point 代表当前的点位 [经纬度] 例如 :[[120.6666],[30.8888]]
[polygon] 代表一个区域坐标
返回true 或 false