-
Notifications
You must be signed in to change notification settings - Fork 1
Map Search Autocomplete
On larger screens there is a search input in the top left corner that has an autocomplete dropdown for the authorization data (as shown above).
On smaller screens there is a search button in the same top left corner that when clicked will display a popup with an autocomplete list. Both of these autocomplete components will work in the same way.
There are 3 kinds of results that are displayed in the autocomplete dropdown or list:
- Authorizations/facilities that match by
Regulated Party
,Facility Location
, orAuthorization Number
- Authorizations/facilities that match by
Postal Code
(which is extracted from theFacility Location
) - Places that match a list of cities/towns/etc in BC (see the Places section below for more details)
-
The user must type in at least 3 characters for the autocompletion dropdown or list to appear.
-
If the search text looks like a postal code (starting with a 'V' and following the postal code format of V#V #V#), then the top 3 matching postal codes (found from facility addresses) that start with the search text will be shown.
-
If the search text only contains numbers, then it is assumed to be the
Authorization Number
. In that case the top matching facilities whose authorization numbers start with the search text will be displayed. -
If the search text is not a postal code or a number, then the top 3 places in BC are displayed by looking them up from a hardcoded list of names. See more details below about this list of places.
-
The top matching facilities (by
Regulated Party
andFacility Location
) are always included as well. -
The autocomplete results are limited to the top 6 results. So if there are no matching postal codes or places, then all 6 will be facilities. If there are postal codes or places, then it will be a combination of both.
There is a file that we generated that contains a list of 3266 place names and locations (latitude/longitude) found in BC. This list was extracted from the BC Gazetteer, which can be downloaded in CSV and XLSX format from here: BC Gazetteer - Open Government
The file contains about 41,000 places! Of these, a subset of places were extracted based on the feature type. It was decided to include the following feature types:
- City
- Community, Recreational Community, and Urban Community
- District Municipality, Mountain Resort Municipality, and Resort Municipality
- Landing
- Locality
- Indian Reserve-Réserve indienne
- Town
- Village, First Nation Village
All places that have the above feature type were extracted and put in a places.json
file which is used in the OMRR web application.
The input places.csv
file and the JavaScript code (places.js
) to do the extraction are included in the repo in the frontend/scripts
folder.
If you need to re-generate the list (or add or remove feature types), then simply run node places.js
from the scripts folder to generate a new JSON file. Then copy the output frontend/scripts/places.json
file from the scripts folder into the frontend/public
folder, replacing the existing file.
The places.csv
file was manually created by downloading the XLSX file from above, and removing all the columns that aren't needed, only keeping (and renaming) these 5 columns: name,featureType,code,lat,lng
. Then it was exported as a CSV file to keep the file size as small as possible.
There is also this reference for BC place names which uses the same data source - BC Geographical Names