Freika/dawarich · warning

[ReplayMarker] Invalid coordinates:

Error message

[ReplayMarker] Invalid coordinates:

What it means

ReplayMarkerLayer.showMarker rejects coordinates that are undefined or NaN (Number.isNaN checks) before building the marker FeatureCollection. The warn echoes both values, so "undefined 51.5" means lon was missing while lat parsed. Any replay timeline seeking to a point whose lon/lat are absent or non-numeric trips this and the marker simply does not move.

Source

Thrown at app/javascript/maps_maplibre/layers/replay_marker_layer.js:68

        },
      },
    ]
  }

  /**
   * Show marker at specified coordinates
   * @param {number} lon - Longitude
   * @param {number} lat - Latitude
   * @param {Object} properties - Additional point properties (including emoji)
   */
  showMarker(lon, lat, properties = {}) {
    if (
      lon === undefined ||
      lat === undefined ||
      Number.isNaN(lon) ||
      Number.isNaN(lat)
    ) {
      console.warn("[ReplayMarker] Invalid coordinates:", lon, lat)
      return
    }

    const emoji = properties.emoji
    const hasEmoji = emoji && typeof emoji === "string" && emoji.trim() !== ""

    const data = {
      type: "FeatureCollection",
      features: [
        {
          type: "Feature",
          geometry: {
            type: "Point",
            coordinates: [lon, lat],
          },
          properties: properties,
        },
      ],

View on GitHub (pinned to 97fad417c5)

Solutions

  1. Check the point feeding showMarker at the call site — usually longitude or latitude is undefined/null for that replay frame; skip such frames.
  2. Parse/normalize coordinates to finite numbers before calling showMarker (Number.isFinite(+lon)).
  3. Tighten the guard itself: Number.isNaN misses non-numeric strings and null, so use Number.isFinite(lon) && Number.isFinite(lat) after coercion.

Example fix

// before
if (
  lon === undefined ||
  lat === undefined ||
  Number.isNaN(lon) ||
  Number.isNaN(lat)
) {
  console.warn("[ReplayMarker] Invalid coordinates:", lon, lat)
  return
}

// after
if (!Number.isFinite(lon) || !Number.isFinite(lat)) {
  console.warn("[ReplayMarker] Invalid coordinates:", lon, lat)
  return
}
Defensive patterns

Strategy: type-guard

Validate before calling

const lon = Number(rawLon)
const lat = Number(rawLat)
if (!Number.isFinite(lon) || !Number.isFinite(lat)) return

Type guard

const isFiniteCoordPair = (lon, lat) =>
  Number.isFinite(Number(lon)) && Number.isFinite(Number(lat))

Prevention

When it happens

Trigger: Scrubbing the replay timeline to an index whose point lacks longitude or latitude (null in the dataset), string coordinates that are not pre-parsed (Number.isNaN("abc") is false, but undefined fields are the usual case), or arithmetic on missing values producing NaN (e.g. lon computed as a + undefined).

Common situations: Points imported with missing coordinate fields; replay data sliced from a sparse array where some frames are placeholders; refactors renaming lon/lng keys so one reads undefined; interpolated frames computing NaN from bad math.

Related errors


AI-assisted analysis of Freika/dawarich@97fad417c5 (2026-08-21). Data as JSON: /api/errors/7da4d8c24be4095d. Report an issue: GitHub.