Skip to content

Latest commit

 

History

History
46 lines (32 loc) · 1.78 KB

mapbox-gl-ogc-feature-collection.md

File metadata and controls

46 lines (32 loc) · 1.78 KB

mapbox-gl-ogc-feature-collection

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.

Links

Software version

This example uses Maplibre GL JS 2.4.0.

Required and supported Conformance classes

The plugin supports the Core, CRS, Filtering, and GeoJSON conformance classes.

Description

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.