Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

made the legend style configurable. Documented TOC Plugin #1865

Merged
merged 1 commit into from
May 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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