Skip to content

Commit

Permalink
#100 AdaptationOptionsAppraisalMap
Browse files Browse the repository at this point in the history
  • Loading branch information
p-a-s-c-a-l committed Jul 23, 2020
1 parent 57fcc2d commit 5be0571
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default class App extends React.Component {
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedHazardLocalEffectsMap/`} render={(props) => <HazardLocalEffectsMap {...props} isSynchronised={true} />} />
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedRiskAndImpactMap/`} render={(props) => <RiskAndImpactMap {...props} isSynchronised={true} />} />
<Route exact path={`${process.env.PUBLIC_URL}/SynchronisedVulnerabilityMap/`} render={(props) => <VulnerabilityMap {...props} isSynchronised={true} />} />
<Route exact path={`${process.env.PUBLIC_URL}/AdaptationOptionsAppraisalMap/`} render={(props) => <RiskAndImpactMap {...props} isSynchronised={true} showAdaptationScenario={true}/>} />

<Route exact path={process.env.PUBLIC_URL} component={GenericMap} />
</Switch>
Expand Down
7 changes: 5 additions & 2 deletions src/components/GenericMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default class GenericMap extends BasicMap {

if (this.props.isSynchronised === true) {
log.info('rendering two sychronised maps: ' + this.props.isSynchronised);

return (<>
<LeafletMap
loading={this.state.loading}
Expand All @@ -74,7 +75,8 @@ export default class GenericMap extends BasicMap {
exclusiveGroups={this.state.exclusiveGroups}
mapId={'synchronisedMapA'}
ref={(mapComponent) => (this.mapComponentA = mapComponent)}
fly='true'
fly={true}
showAdaptationScenario={false}
/>
<LeafletMap
loading={this.state.loading}
Expand All @@ -85,7 +87,8 @@ export default class GenericMap extends BasicMap {
exclusiveGroups={this.state.exclusiveGroups}
mapId={'synchronisedMapB'}
ref={(mapComponent) => (this.mapComponentB = mapComponent)}
fly='false'
fly={false}
showAdaptationScenario={true}
/>
</>);
} else {
Expand Down
11 changes: 9 additions & 2 deletions src/components/commons/LeafletMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,14 @@ export default class LeafletMap extends React.Component {
getUrl(name) {
for (var i = 0; i < this.props.overlays.length; i++) {
if (this.props.overlays[i].name === name) {
return this.props.overlays[i].url;

// hacketyhack
if(this.props.showAdaptationScenario) {
log.debug(`changing URL parameter of layer ${name} to STUDY_VARIANT='ADAPTATION-01'`);
return this.props.overlays[i].url.replace("STUDY_VARIANT='BASELINE'","STUDY_VARIANT='ADAPTATION-01'");
} else {
return this.props.overlays[i].url;
}
}
}

Expand Down Expand Up @@ -410,7 +417,7 @@ export default class LeafletMap extends React.Component {
const identify = true;
layerArray.unshift(
<WMSLayer
key={overlay.name}
key={`${overlay.name}_${this.props.showAdaptationScenario}`}
layers={this.getLayers(overlay.name)}
url={this.getUrl(overlay.name)}
transparent="true"
Expand Down

0 comments on commit 5be0571

Please sign in to comment.