I've specified two <Source> elements under ReactMapGL trying to load two different FeatureCollections with different coloring. It doesn't work when both Sources are present as it hides the first (id: maps-with-yield) and shows the latter (id: maps-without-yield).
The following warning is also printed for the first Source.
TypeError: Cannot read property 'fill-color' of undefined
Are we not allowed to use multiple sources or am I doing something wrong here?
<MapGL
{...viewport}
mapboxApiAccessToken={accessToken}
onViewportChange={viewport => setViewport(viewport)}
onHover={onHover}
onClick={onClick}
onLoad={onLoad}
width="100%"
height="100%"
scrollZoom={false}
dragRotate={false}
touchRotate={false}
keyboard={false}
>
{map && map.features.length > 0 ? (
<Source id="maps-with-yield" type="geojson" data={map}>
<Layer
id="data"
type="fill"
paint={{
'fill-color': {
property: 'yield',
stops: [
[minYield, worstYieldColor],
[maxYield, bestYieldColor]
]
},
'fill-outline-color': '#fff'
}}
/>
</Source>
) : null}
{mapWithoutYield && mapWithoutYield.features.length > 0 ? (
<Source id="maps-without-yield" type="geojson" data={mapWithoutYield}>
<Layer
id="data"
type="fill"
paint={{
'fill-color': '#66AEEC',
'fill-outline-color': '#fff'
}}
/>
</Source>
) : null}
</MapGL>
Note: property yield is always available as I've printed both map and mapWithoutYield data sets and checked.