Reinos.nl internet media examples

Filters in your own Javascript (JSON endpoint)

Maps Locator 4.0.1 Code only

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.

  1. Install Maps Locator and Maps.
  2. 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.
  3. Create the fields, with these short names:
    Short nameTypeNotes
    store_locationMapsSet 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.
    servicesCheckboxesOptions: wifi, parking, wheelchair.
  4. Create the channel stores (Stores) and assign the fields and the category group Store types.
  5. 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).
  6. Put the code in a template.
  7. 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.