Skip to content

now()

now(): number

Defined in: src/util/time_control.ts:65

Returns the current time in milliseconds. When time is frozen via setNow(), returns the frozen timestamp. Otherwise returns real browser time (performance.now() or Date.now()).

Returns

number

Current time in milliseconds

Example

// Measure elapsed time
const start = maplibregl.now();
// ... later ...
const elapsed = maplibregl.now() - start;

// During frozen time
maplibregl.setNow(16.67);
console.log(maplibregl.now()); // 16.67
maplibregl.restoreNow();
console.log(maplibregl.now()); // real time