nrenner / brouter-web

Web client for BRouter, a routing engine based on OpenStreetMap
https://brouter.de/brouter-web/
MIT License
373 stars 74 forks source link

Support remote GeoJSON layers #727

Closed zod closed 1 year ago

zod commented 1 year ago

I've tried to achieve similar things as #677 and wanted to add a remote GeoJSON as as layer. Currently this seems to be possible using maplibre with a style file which uses a geojson source. It feels a bit sluggish and comments on leaflet-maplibre mention performance issues.

Leaflet also provides GeoJSON support, but it seems there is currently no way to specify them in layer configuration.

I've implemented a minimal version which also support the simplestyle-spec.

To test it you can add a layer configuration which uses the example.json from simplestyle-spec

{
    "geometry": null,
    "properties": {
        "id": "geojson-simplestyle",
        "overlay": true,
        "type": "geojson",
        "url": "https://raw.githubusercontent.com/mapbox/simplestyle-spec/master/1.1.0/example.geojson"
    },
    "type": "Feature"
}

Because I'm not familiar with JS development there's a pending issue: Husky warned me because fetch isn't available in all supported browsers. I thought babel & polyfills should take care of that...

zod commented 1 year ago

I didn't add support for markers because it seems Leaflet doesn't support specifying colors by default

Other than the issue described above it's ready (and I've removed the draft status).

nrenner commented 1 year ago

Thanks for your contribution!

nrenner commented 1 year ago

I didn't add support for markers because it seems Leaflet doesn't support specifying colors by default

We use Leaflet.vector-markers (fork) that allows to set marker color, icon and probably also size, see example. Currently, our default icon set is Font Awesome, but that might change, and we only include a subset of Maki icons.