Skip to content

Commit

Permalink
made the legend style configurable. Documented TOC Plugin (#1865)
Browse files Browse the repository at this point in the history
  • Loading branch information
offtherailz authored May 23, 2017
1 parent 35c19ba commit 1153033
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
5 changes: 3 additions & 2 deletions web/client/components/TOC/DefaultLayer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ var DefaultLayer = React.createClass({
groups: React.PropTypes.array,
currentZoomLvl: React.PropTypes.number,
scales: React.PropTypes.array,
additionalTools: React.PropTypes.array
additionalTools: React.PropTypes.array,
legendOptions: React.PropTypes.object
},
getDefaultProps() {
return {
Expand Down Expand Up @@ -145,7 +146,7 @@ var DefaultLayer = React.createClass({
}
return (<div position="collapsible" className="collapsible-toc">
<div style={{minHeight: "35px"}}>{tools}</div>
<div><WMSLegend node={this.props.node} currentZoomLvl={this.props.currentZoomLvl} scales={this.props.scales}/></div>
<div><WMSLegend node={this.props.node} currentZoomLvl={this.props.currentZoomLvl} scales={this.props.scales} {...this.props.legendOptions}/></div>
</div>);
},
renderTools() {
Expand Down
7 changes: 6 additions & 1 deletion web/client/components/TOC/fragments/WMSLegend.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,24 @@ var Legend = require('./legend/Legend');
var WMSLegend = React.createClass({
propTypes: {
node: React.PropTypes.object,
legendContainerStyle: React.PropTypes.object,
legendStyle: React.PropTypes.object,
showOnlyIfVisible: React.PropTypes.bool,
currentZoomLvl: React.PropTypes.number,
scales: React.PropTypes.array
},
getDefaultProps() {
return {
legendContainerStyle: {
marginLeft: "15px"
},
showOnlyIfVisible: false
};
},
render() {
let node = this.props.node || {};
if (this.canShow(node) && node.type === "wms" && node.group !== "background") {
return <div style={{marginLeft: "15px"}}><Legend layer={node} currentZoomLvl={this.props.currentZoomLvl} scales={this.props.scales}/></div>;
return <div style={this.props.legendContainerStyle}><Legend style={this.props.legendStyle} layer={node} currentZoomLvl={this.props.currentZoomLvl} scales={this.props.scales}/></div>;
}
return null;
},
Expand Down
6 changes: 4 additions & 2 deletions web/client/components/TOC/fragments/legend/Legend.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ const Legend = React.createClass({
legendHeigth: React.PropTypes.number,
legendWidth: React.PropTypes.number,
legendOptions: React.PropTypes.string,
style: React.PropTypes.object,
currentZoomLvl: React.PropTypes.number,
scales: React.PropTypes.array
},
getDefaultProps() {
return {
legendHeigth: 12,
legendWidth: 12,
legendOptions: "forceLabels:on;fontSize:10"
legendOptions: "forceLabels:on;fontSize:10",
style: {maxWidth: "100%"}
};
},
render() {
Expand Down Expand Up @@ -53,7 +55,7 @@ const Legend = React.createClass({
pathname: urlObj.pathname,
query: query
});
return <img src={legendUrl} style={{maxWidth: "100%"}}/>;
return <img src={legendUrl} style={this.props.style}/>;
}
return null;
}
Expand Down

0 comments on commit 1153033

Please sign in to comment.