Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/8032 ogc api features #184

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

fapola
Copy link
Member

@fapola fapola commented Sep 16, 2024

Adds new component with two stories to add a OGC Api Feature as Geojson to the maplibre map.

In the OGC API Feature Loader story a URL can be passed to a input field to get features from a OGC API Feature Endpoint similar to the MlWmsLoader story. The Feature can also be styled inside the story component.

@cioddi
Copy link
Member

cioddi commented Sep 16, 2024

The implementation looks solid.

I’m considering adding an option to either request all features upfront or dynamically request features based on the current bounding box (bbox) whenever the view changes. @MartinAlzueta and I previously developed something similar for a WFS integration.

useEffect(() => {
        if (!mapHook.map) return;

        const getDataHandler = () => {
            const southWest = mapHook.map.getBounds().getSouthWest();
            const northEast = mapHook.map.getBounds().getNorthEast();

            fetch(props.url + 'service=WFS&version=2.0.0&request=GetFeature&typeNames=' + props.typeNames + '&outputFormat=application/json'
                + '&bbox='
                + southWest.lat + ','
                + southWest.lng + ','
                + northEast.lat + ','
                + northEast.lng).then(res => {

                    return res.json()
                }).then(data => {
                    setGeojson(data);
                })
        };
        mapHook.map.on('moveend', getDataHandler)

        return () => {
            mapHook.map.off('moveend', getDataHandler)
        }
    }, [mapHook.map])

Additionally, we should introduce a configurable GeoJsonLayer properties option. This would also allow us to limit fetch requests to only trigger when the view is within a specified zoom range (minZoom and maxZoom).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants