in modules/layers/src/geojson-layer/geojson-layer.js [121:331]
renderLayers() {
const {features, featuresDiff} = this.state;
const {pointFeatures, lineFeatures, polygonFeatures, polygonOutlineFeatures} = features;
// Layer composition props
const {stroked, filled, extruded, wireframe, material, transitions} = this.props;
// Rendering props underlying layer
const {
lineWidthUnits,
lineWidthScale,
lineWidthMinPixels,
lineWidthMaxPixels,
lineJointRounded,
lineMiterLimit,
pointRadiusUnits,
pointRadiusScale,
pointRadiusMinPixels,
pointRadiusMaxPixels,
elevationScale,
lineDashJustified
} = this.props;
// Accessor props for underlying layers
const {
getLineColor,
getFillColor,
getRadius,
getLineWidth,
getLineDashArray,
getElevation,
updateTriggers
} = this.props;
const PolygonFillLayer = this.getSubLayerClass('polygons-fill', SolidPolygonLayer);
const PolygonStrokeLayer = this.getSubLayerClass('polygons-stroke', PathLayer);
const LineStringsLayer = this.getSubLayerClass('line-strings', PathLayer);
const PointsLayer = this.getSubLayerClass('points', ScatterplotLayer);
// Filled Polygon Layer
const polygonFillLayer =
this.shouldRenderSubLayer('polygons-fill', polygonFeatures) &&
new PolygonFillLayer(
{
_dataDiff: featuresDiff.polygonFeatures && (() => featuresDiff.polygonFeatures),
extruded,
elevationScale,
filled,
wireframe,
material,
getElevation: this.getSubLayerAccessor(getElevation),
getFillColor: this.getSubLayerAccessor(getFillColor),
getLineColor: this.getSubLayerAccessor(getLineColor),
transitions: transitions && {
getPolygon: transitions.geometry,
getElevation: transitions.getElevation,
getFillColor: transitions.getFillColor,
getLineColor: transitions.getLineColor
}
},
this.getSubLayerProps({
id: 'polygons-fill',
updateTriggers: {
getElevation: updateTriggers.getElevation,
getFillColor: updateTriggers.getFillColor,
getLineColor: updateTriggers.getLineColor
}
}),
{
data: polygonFeatures,
getPolygon: getCoordinates
}
);
const polygonLineLayer =
!extruded &&
stroked &&
this.shouldRenderSubLayer('polygons-stroke', polygonOutlineFeatures) &&
new PolygonStrokeLayer(
{
_dataDiff:
featuresDiff.polygonOutlineFeatures && (() => featuresDiff.polygonOutlineFeatures),
widthUnits: lineWidthUnits,
widthScale: lineWidthScale,
widthMinPixels: lineWidthMinPixels,
widthMaxPixels: lineWidthMaxPixels,
rounded: lineJointRounded,
miterLimit: lineMiterLimit,
dashJustified: lineDashJustified,
getColor: this.getSubLayerAccessor(getLineColor),
getWidth: this.getSubLayerAccessor(getLineWidth),
getDashArray: this.getSubLayerAccessor(getLineDashArray),
transitions: transitions && {
getPath: transitions.geometry,
getColor: transitions.getLineColor,
getWidth: transitions.getLineWidth
}
},
this.getSubLayerProps({
id: 'polygons-stroke',
updateTriggers: {
getColor: updateTriggers.getLineColor,
getWidth: updateTriggers.getLineWidth,
getDashArray: updateTriggers.getLineDashArray
}
}),
{
data: polygonOutlineFeatures,
getPath: getCoordinates
}
);
const pathLayer =
this.shouldRenderSubLayer('linestrings', lineFeatures) &&
new LineStringsLayer(
{
_dataDiff: featuresDiff.lineFeatures && (() => featuresDiff.lineFeatures),
widthUnits: lineWidthUnits,
widthScale: lineWidthScale,
widthMinPixels: lineWidthMinPixels,
widthMaxPixels: lineWidthMaxPixels,
rounded: lineJointRounded,
miterLimit: lineMiterLimit,
dashJustified: lineDashJustified,
getColor: this.getSubLayerAccessor(getLineColor),
getWidth: this.getSubLayerAccessor(getLineWidth),
getDashArray: this.getSubLayerAccessor(getLineDashArray),
transitions: transitions && {
getPath: transitions.geometry,
getColor: transitions.getLineColor,
getWidth: transitions.getLineWidth
}
},
this.getSubLayerProps({
id: 'line-strings',
updateTriggers: {
getColor: updateTriggers.getLineColor,
getWidth: updateTriggers.getLineWidth,
getDashArray: updateTriggers.getLineDashArray
}
}),
{
data: lineFeatures,
getPath: getCoordinates
}
);
const pointLayer =
this.shouldRenderSubLayer('points', pointFeatures) &&
new PointsLayer(
{
_dataDiff: featuresDiff.pointFeatures && (() => featuresDiff.pointFeatures),
stroked,
filled,
radiusUnits: pointRadiusUnits,
radiusScale: pointRadiusScale,
radiusMinPixels: pointRadiusMinPixels,
radiusMaxPixels: pointRadiusMaxPixels,
lineWidthUnits,
lineWidthScale,
lineWidthMinPixels,
lineWidthMaxPixels,
getFillColor: this.getSubLayerAccessor(getFillColor),
getLineColor: this.getSubLayerAccessor(getLineColor),
getRadius: this.getSubLayerAccessor(getRadius),
getLineWidth: this.getSubLayerAccessor(getLineWidth),
transitions: transitions && {
getPosition: transitions.geometry,
getFillColor: transitions.getFillColor,
getLineColor: transitions.getLineColor,
getRadius: transitions.getRadius,
getLineWidth: transitions.getLineWidth
}
},
this.getSubLayerProps({
id: 'points',
updateTriggers: {
getFillColor: updateTriggers.getFillColor,
getLineColor: updateTriggers.getLineColor,
getRadius: updateTriggers.getRadius,
getLineWidth: updateTriggers.getLineWidth
}
}),
{
data: pointFeatures,
getPosition: getCoordinates,
highlightedObjectIndex: this._getHighlightedIndex(pointFeatures)
}
);
return [
// If not extruded: flat fill layer is drawn below outlines
!extruded && polygonFillLayer,
polygonLineLayer,
pathLayer,
pointLayer,
// If extruded: draw fill layer last for correct blending behavior
extruded && polygonFillLayer
];
}