2017-09-26 13:40:04 -07:00
|
|
|
/* eslint react/prop-types:0 */
|
2017-09-22 14:43:40 -07:00
|
|
|
import React from 'react';
|
2017-09-26 13:32:27 -07:00
|
|
|
import MapboxStyleSheet from '../utils/MapboxStyleSheet';
|
2017-10-04 12:51:36 -07:00
|
|
|
import { getFilter } from '../utils';
|
2017-09-22 14:43:40 -07:00
|
|
|
|
|
|
|
|
class AbstractLayer extends React.Component {
|
|
|
|
|
get baseProps () {
|
|
|
|
|
return {
|
|
|
|
|
id: this.props.id,
|
|
|
|
|
sourceID: this.props.sourceID,
|
2017-09-26 13:32:27 -07:00
|
|
|
reactStyle: this.getStyle(),
|
2017-09-22 14:43:40 -07:00
|
|
|
minZoomLevel: this.props.minZoomLevel,
|
|
|
|
|
maxZoomLevel: this.props.maxZoomLevel,
|
|
|
|
|
aboveLayerID: this.props.aboveLayerID,
|
|
|
|
|
belowLayerID: this.props.belowLayerID,
|
|
|
|
|
layerIndex: this.props.layerIndex,
|
2017-10-04 12:51:36 -07:00
|
|
|
filter: getFilter(this.props.filter),
|
2017-09-22 14:43:40 -07:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-26 13:32:27 -07:00
|
|
|
getStyle () {
|
|
|
|
|
if (!this.props.style) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (MapboxStyleSheet.isStyleSheet(this.props.style)) {
|
|
|
|
|
return this.props.style;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return MapboxStyleSheet.create(this.props.style);
|
|
|
|
|
}
|
2017-09-22 14:43:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default AbstractLayer;
|