Skip to content

Commit

Permalink
Merge pull request #1574 from hackforla/1539-Address-Search-restrict-…
Browse files Browse the repository at this point in the history
…typeahead-to-relevant-locations

1539 address search restrict typeahead to relevant locations
  • Loading branch information
wmb1232 authored Sep 20, 2023
2 parents 5b16fd7 + 28560d4 commit 8c2281d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/Map/controls/MapSearch.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class MapSearch extends React.Component {
localGeocoder: searchTerm => {
const { geoFilterType } = this.props;
const searchFilter = new RegExp(searchTerm, 'i');

switch(geoFilterType) {
case GEO_FILTER_TYPES.address:
return [];
Expand All @@ -106,6 +105,14 @@ class MapSearch extends React.Component {
}));
}
},
filter: (item) => {
// Early return if item is undefined
if (item?.context === undefined || item.context.length === 0) return;
// Return only places that are in los angeles county as district, this can be adjusted to include more places
return item.context.some( (i) => {
return (i.id.split(".").shift() === 'district' && i.text === "Los Angeles County");
});
}
});

// This event fires upon an Address Search submission
Expand Down

0 comments on commit 8c2281d

Please sign in to comment.