Skip to content

Time slider sometimes fails to filter #968

Open

Description

@1ec5

On OSM World Discord, @CharliePlett noticed that the time slider on the homepage sometimes fails to initialize, breaking the map. Here’s the specific URL they loaded:

https://www.openhistoricalmap.org/#map=4/41.44/-1.89&layers=O&date=1925-02-04&daterange=1825-01-01,2025-12-31

The time slider’s labels are missing and the map is unfiltered.

The following errors appear in the browser console:

Uncaught TypeError: Cannot read properties of undefined (reading sources)) at 1, getFilteredvectorLayers (application-36605210014253.js:247:14006) at i._addDateFiltersTovectorLayers (application: 3662521d.d14253.js:247: 14328) at application-366521d-dd14253.js: 24748941 Failed to load resource: the server responded with a status of 404 (Not Found)

They’re able to reproduce the issue when logged out in private browsing mode on desktop Chrome and Firefox but not on a mobile browser.

Based on the error message, the exception seems to occur here, and nothing catches it, so the time slider goes kaput:

https://github.com/OpenHistoricalMap/leaflet-ohm-timeslider-v2/blob/dd0acbdc9432fae6a4d09a17a4848c391e5064f0/leaflet-ohm-timeslider.js#L651

At a glance, I don’t see a reason why the style would have no sources, but it may be worth noting that, in general, individual fields deep within the result of getStyle() aren’t as reliable as some of the other accessors like getSource(). This particular statement would be simpler with a call to getSource() and probably less likely to throw an exception.

More broadly, this code is entirely redundant to the maplibre-gl-dates plugin that we publish. #914 tracks a rewrite of the time slider that would depend on this plugin instead of the current date filtering code.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions