Skip to content

Commit

Permalink
map clears and resets on dataset change, closes #76 closes #74
Browse files Browse the repository at this point in the history
  • Loading branch information
colinmegill committed Jan 8, 2017
1 parent 5080b5d commit 88982be
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/components/map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,23 @@ class Map extends React.Component {
this.props.browserDimensions &&
!this.state.map
) {
console.info("creating map")
this.createMap();
}

if (
prevProps.browserDimensions &&
prevProps.browserDimensions.height &&
this.props.browserDimensions.height !== prevProps.browserDimensions.height
this.state.map && // we have a map
prevProps.datasetGuid &&
this.props.datasetGuid &&
prevProps.datasetGuid !== this.props.datasetGuid // and the dataset has changed
) {
/* optionally clear and re-layout the map here */
console.info("removing map")
this.state.map.remove()
this.setState({
map: null,
tips: false
})

}

if (
Expand All @@ -60,10 +68,13 @@ class Map extends React.Component {
this.props.nodes &&
!this.state.tips /* we haven't already drawn tips */
) {
console.log('drawing tips & transmission')
addAllTipsToMap(this.props.nodes, this.props.metadata, this.props.colorScale, this.state.map);
addTransmissionEventsToMap(this.props.nodes, this.props.metadata, this.props.colorScale, this.state.map);
// don't redraw on every rerender - need to seperately handle virus change redraw
this.setState({tips: true});
this.setState({
tips: true
});
}

}
Expand Down

0 comments on commit 88982be

Please sign in to comment.