Add multiple geometries from one GeoJSON source
Replicates the MapLibre example Add multiple geometries from one GeoJSON source: a park boundary polygon and its points of interest, from a single source.
The complete document
Section titled “The complete document”# yaml-language-server: $schema=https://docs.maplibre-yaml.org/schema/latest/map.schema.json# Gallery twin of https://maplibre.org/maplibre-gl-js/docs/examples/add-multiple-geometries-from-one-geojson-source/# One named source, two layers: the fill draws only polygons, the circle only points.type: mapid: add-multiple-geometries-from-one-geojson-sourceconfig: center: [-121.403732, 40.492392] zoom: 10 mapStyle: "https://demotiles.maplibre.org/style.json"sources: park: type: geojson data: type: FeatureCollection features: - type: Feature properties: { name: Lassen boundary } geometry: type: Polygon coordinates: - - [-121.353637, 40.584978] - [-121.284551, 40.584758] - [-121.275349, 40.541646] - [-121.246768, 40.541017] - [-121.251343, 40.423383] - [-121.32687, 40.423768] - [-121.360619, 40.43155] - [-121.363694, 40.409124] - [-121.439713, 40.409197] - [-121.439711, 40.423791] - [-121.572133, 40.423548] - [-121.577415, 40.550766] - [-121.539486, 40.558107] - [-121.520284, 40.572459] - [-121.487219, 40.550822] - [-121.446951, 40.56319] - [-121.370644, 40.563267] - [-121.353637, 40.584978] - type: Feature properties: { name: Visitor center } geometry: type: Point coordinates: [-121.415061, 40.506229] - type: Feature properties: { name: Trailhead } geometry: type: Point coordinates: [-121.505184, 40.488084]layers: - id: park-boundary type: fill source: park filter: ["==", ["geometry-type"], "Polygon"] paint: fill-color: "#888888" fill-opacity: 0.4 - id: park-points type: circle source: park filter: ["==", ["geometry-type"], "Point"] paint: circle-radius: 6 circle-color: "#b42222"What to notice
Section titled “What to notice”- The block-level
sources:record is fetched once and shared; each layer selects its geometry with a["==", ["geometry-type"], …]filter. - The same pattern powers the clusters page (three layers, one source).