gramps-project / gramps-web

Frontend for Gramps Web
https://www.grampsweb.org
GNU Affero General Public License v3.0
397 stars 51 forks source link

Replace custom date filtering with maplibre-gl-dates #479

Closed 1ec5 closed 1 month ago

1ec5 commented 1 month ago

This replaces the custom date filtering code for the OpenHistoricalMap basemap with maplibre-gl-dates, which is forward-compatible with expression-based filters.

1ec5 commented 1 month ago

I’m unable to test this change locally because of the following error:

gramps-frontend-dev  | Error while transforming src/components/GrampsjsMap.js: Could not resolve import "@openhistoricalmap/maplibre-gl-dates".
gramps-frontend-dev  | 
gramps-frontend-dev  |   3 | import 'maplibre-gl'
gramps-frontend-dev  |   4 | import '@maplibre/maplibre-gl-leaflet'
gramps-frontend-dev  | > 5 | import '@openhistoricalmap/maplibre-gl-dates'
gramps-frontend-dev  |     |        ^
gramps-frontend-dev  |   6 | import './GrampsjsMapOverlay.js'
gramps-frontend-dev  |   7 | import './GrampsjsMapMarker.js'
gramps-frontend-dev  |   8 | import {fireEvent} from '../util.js'
gramps-frontend-dev  | 

I’m not sure why this error occurs, since the @openhistoricalmap/maplibre-gl-dates package has been installed. One unusual aspect is that, as long as this comes after the maplibre-gl import, the module doesn’t export anything; it only adds a method to an existing global maplibregl object.

DavidMStraub commented 1 month ago

Thanks, big simplification!

I got the import error at first as well, but it worked after restarting the web dev server (npm run start).

It works as expected in the browser, but I see a lot of errors in the console, they are all of the type

layers.land.filter[3][0]: expected one of [==, !=, >, >=, <, <=, in, !in, all, any, none, has, !has], "let" found

It looks like this error occurs for all layers.

1ec5 commented 1 month ago

Thanks, I fixed the error in OpenHistoricalMap/maplibre-gl-dates@d6b6da1a8314bb8758021074e7db45669c8dfa4b and upgraded the library.