1. npm 安装 turf "@turf/turf": "^7.0.0",
import * as turf from '@turf/turf';
// 判断是否在围栏里
export function isCheckInPoint(fence, points) {
// 假设这是你的不规则多边形的坐标数组
const polygonCoords = [fence]
// 假设这是你要判断的点的坐标
const pointCoords = points;
// 创建多边形和点的Feature
const polygon = turf.polygon(polygonCoords);
const point = turf.point(pointCoords);
// 使用Turf.js的booleanPointInPolygon方法判断点是否在多边形内
const insidePolygon = turf.booleanPointInPolygon(point, polygon);
return insidePolygon //true 在打卡范围 false 不在打卡范围
}