Skip to content

Commit 21bbc91

Browse files
committed
fix: corner cases with rounding
1 parent 523c531 commit 21bbc91

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Map.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,8 @@ function MapComponent({
483483
const hasRaw = rawLat !== undefined && rawLng !== undefined;
484484
const hasFlp = flpLat !== undefined && flpLng !== undefined;
485485

486-
const to5 = (num) => (num ? num.toFixed(5) : num); // Within 1.1m is considered a match
487-
const isMatch = hasRaw && hasFlp && to5(rawLat) === to5(flpLat) && to5(rawLng) === to5(flpLng);
488-
486+
const EPSILON = 0.00001; // Approx 1.1 meters at the equator
487+
const isMatch = hasRaw && hasFlp && Math.abs(rawLat - flpLat) < EPSILON && Math.abs(rawLng - flpLng) < EPSILON;
489488
const updateMarker = (markerRefName, position, color, zIndex, scale = 2) => {
490489
if (!position) {
491490
if (vehicleMarkersRef.current[markerRefName]) {

0 commit comments

Comments
 (0)