polylines tooltip content

This commit is contained in:
ISA
2024-08-10 10:32:37 +02:00
parent b1f7b700ca
commit b7116a1e6f
142 changed files with 14451 additions and 4281 deletions

19
utils/geometryUtils.js Normal file
View File

@@ -0,0 +1,19 @@
// utils/geometryUtils.js
export const findClosestPoints = (coordinates, newPoint, map) => {
if (!map) {
console.error("Map is not defined. Cannot find closest points.");
return [];
}
let minDist = Infinity;
let closestPair = [];
for (let i = 1; i < coordinates.length; i++) {
const dist = L.LineUtil.pointToSegmentDistance(map.latLngToLayerPoint(newPoint), map.latLngToLayerPoint(coordinates[i - 1]), map.latLngToLayerPoint(coordinates[i]));
if (dist < minDist) {
minDist = dist;
closestPair = [coordinates[i - 1], coordinates[i], i];
}
}
return closestPair;
};