Skip to content

Commit

Permalink
Merge pull request #1853 from hackforla/1837-Selecting-an-NC-when-ano…
Browse files Browse the repository at this point in the history
…ther-selected

removed conditional for resetting boundary
  • Loading branch information
Brandoncyu authored Nov 8, 2024
2 parents 0e5455a + 19d47b6 commit eee59bb
Showing 1 changed file with 19 additions and 44 deletions.
63 changes: 19 additions & 44 deletions components/Map/Map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ const styles = (theme) => ({
});

// Define feature layers
const hoverables = ['nc-fills', 'cc-fills'];
const featureLayers = ['request-circles', ...hoverables];
const featureLayers = ['request-circles','nc-fills'];

class Map extends React.Component {
// Note: 'this.context' is defined using the static contextType property
Expand Down Expand Up @@ -474,51 +473,27 @@ class Map extends React.Component {
const features = this.getAllFeaturesAtPoint(e.point);
for (let i = 0; i < features.length; i += 1) {
const feature = features[i];
if (feature.layer.id == "nc-fills") {
this.setState({ address: null });

if (
!isEmpty(this.props.selectedNcId) &&
!isEmpty(feature.properties.NC_ID) &&
this.props.selectedNcId !== feature.properties.NC_ID
) {
// Since click is for another district

// Reset boundaries selection
this.resetBoundaries();

// Collapse boundaries section
dispatchCloseBoundaries();
this.resetAddressSearch(); // Clear address search input
dispatchCloseBoundaries(); // Collapse boundaries section

// Reset Address Search input field
this.resetAddressSearch();

// Reset Map.
this.reset();

return;
}
const selectedCouncilId = Number(feature.properties.NC_ID);
const newSelectedCouncil = councils.find(
({ councilId }) => councilId === selectedCouncilId
);
const newSelected = isEmpty(newSelectedCouncil)
? null
: [newSelectedCouncil];

if (hoverables.includes(feature.layer.id) && !feature.state.selected) {
switch (feature.layer.id) {
case 'nc-fills':
this.setState({ address: null });
this.resetAddressSearch(); // Clear address search input
dispatchCloseBoundaries(); // Collapse boundaries section
const selectedCouncilId = Number(feature.properties.NC_ID);
const newSelectedCouncil = councils.find(
({ councilId }) => councilId === selectedCouncilId
);
const newSelected = isEmpty(newSelectedCouncil)
? null
: [newSelectedCouncil];
dispatchUpdateSelectedCouncils(newSelected);
dispatchUpdateUnselectedCouncils(councils);
dispatchUpdateNcId(selectedCouncilId);
return this.ncLayer.selectRegion(feature.id);
case 'cc-fills':
return this.ccLayer.selectRegion(feature.id);
default:
return null;
}
dispatchUpdateSelectedCouncils(newSelected);
dispatchUpdateUnselectedCouncils(councils);
dispatchUpdateNcId(selectedCouncilId);

return this.ncLayer.selectRegion(feature.id);
} else{
return null;
}
}
};
Expand Down

0 comments on commit eee59bb

Please sign in to comment.