The Search template can be set up to filter content by location and display search results on a map.
Which Articles?
The location search can only return article results, not media.
For an article to appear in the results, the following must be in place:
- The article extras must include a field called LOCATION which holds a lat-long value (using the Location Picker is the easiest way to achieve this)
- The LOCATION field must also be set as "searchable" in the field properties
There's no restriction on the template types that can appear in the results. As long as there's a searchable location, the article will appear. That means the Event, Location and Service templates are supported, plus you can create your own template definitions with locations in their article extras.
If you enable the location search, articles without any location data are excluded.
Postcode Radius
The postcode filter is optional. If it's not enabled, results can still be displayed on a map.
Entering a postcode and selecting a radius will restrict the search results to locations within that area. The options in the radius drop-down are fixed to 1, 2, 5, 10 and 20 miles or kilometres - you can choose the units in the article extras.
For the filter to work, and the distance from the postcode to be displayed in the results (see below), the postcode search provider set up in your platform's Postcode worker must return a latitude and longitude in the format described in the postcodeSearch (postcode, provider) article.
Results
The search will return results of a keyword search in exactly the same way as a standard site search for articles. You can display the results in a list or on a map, and in the article extras, choose which is displayed by default.
List View
Results in the list view work best using the "custom" article view described in Search Results.
If a postcode filter has been used, the distance in either miles or kilometres from that postcode is displayed with each result. You can choose the units in the article extras.
Map View
Map results are displayed as a series of pins. Clicking on a pin displays the same text that would appear in the list view.
In the article extras you can choose the map provider (either Open Street Maps or Google, which will require a Google API key in your subsite settings) and the starting location. It's also possible to disable the map, if all you want to display is the list of results with the distance from the postcode that's ben entered.