Mapbox GL JS supports loading GeoJSON data, but mapbox-gl-ogc-feature-collection
offers a more complete implementation - with details such as using the bbox and filtering.
- The plugin is available in a gitlab repository at https://github.com/mkeller3/mapbox-gl-ogc-feature-collection
- There is a live demo at https://mkeller3.github.io/mapbox-gl-ogc-feature-collection/
This example uses Maplibre GL JS 2.4.0.
The plugin supports the Core, CRS, Filtering, and GeoJSON conformance classes.
The package offers a new class (OGCFeatureCollection
) To instantiate it, provide the URL to the landing page and the ID (not the name, not the description) of the desired collection.
import OGCFeatureCollection from 'mapbox-gl-ogc-feature-collection'
map.on('load', () => {
const sourceId = 'collection-src'
new OGCFeatureCollection(sourceId, map, {
url: 'https://demo.pygeoapi.io/stable',
collectionId: 'lakes',
limit: 10000
})
map.addLayer({
'id': 'lyr',
'source': sourceId,
'type': 'fill',
'paint': {
'fill-color': '#B42222',
'fill-opacity': 0.7
}
})
})
The gitlab repository contains a complete demo, including loading the class, and a demo.