A headless site or your own Javascript searches with the JSON endpoint. The tag gives the signed URL, filters sets the fields a request can filter on:
Template
<script>
const searchUrl = '{exp:reinos_maps_locator:search_url channel="stores" filters="services" limit="20"}';
async function findStores(location, services) {
const params = new URLSearchParams({ location, radius: 25 });
services.forEach(service => params.append('filter[services][]', service));
const response = await fetch(`${searchUrl}&${params}`);
const data = await response.json();
// data.status: ok, nearest, no_results or not_found
return data.locations;
}
findStores('utrecht', ['wifi', 'parking']).then(stores => console.log(stores));
</script>Build it in your own site
What this example needs in ExpressionEngine, step by step.
- Install Maps Locator and Maps.
- Create the category group Store types with the categories Bike shop, E-bike specialist, Repair, Rental. The code uses its ID (
category_group="3"): change it to the ID of your group. - Create the fields, with these short names:
Short name Type Notes store_locationMaps Set the field setting Mode to Single location: one marker per store, placed with the search field. Maps Locator indexes that marker, so this one field is the location for the map and the search. servicesCheckboxes Options: wifi,parking,wheelchair. - Create the channel
stores(Stores) and assign the fields and the category group Store types. - In the settings of Maps Locator, turn on Reverse geocoding: a marker of a Maps field is saved as a coordinate, the reverse geocoding looks up its address and city (the city pages and a search on a city need them).
- Put the code in a template.
- Add a few stores (the demo site has 34 bike stores in the Netherlands).
This example comes from the Maps Locator docs: the preview runs exactly the code above.