The planner in a sidebar next to the map, with a select for the travel mode and a template per step (markup="no", see Your own HTML). The events show the route below the planner.
Template
{exp:reinos_maps:html_header}
<style>
.planner-layout { display: flex; gap: 2em; align-items: flex-start; }
.planner-layout aside { flex: 0 0 320px; }
.planner-layout main { flex: 1; }
</style>
<div class="planner-layout">
<aside>
<div id="planner">
<form data-maps-route-form>
<input name="from" placeholder="Waar kom je vandaan?" required>
<button type="button" data-maps-route-locate hidden>📍 Mijn locatie</button>
<select name="travel_mode">
<option value="cycling">Fiets</option>
<option value="walking">Lopen</option>
</select>
<button>Plan route</button>
</form>
<p data-maps-route-status></p>
<div data-maps-route-result hidden>
<h3><span data-maps-route-distance></span> · <span data-maps-route-duration></span></h3>
<ul data-maps-route-steps>
<template data-maps-route-step>
<li><strong data-maps-route-step-instruction></strong> <em data-maps-route-step-distance></em></li>
</template>
</ul>
<a data-maps-route-link="google" target="_blank" rel="noopener">Open in Google Maps</a>
</div>
</div>
</aside>
<main>
{exp:reinos_maps:map width="100%" height="500px"}
{maps:add_marker address="Domplein, Utrecht"}
{maps:route_planner address:to="Domplein, Utrecht" travel_modes="cycling|walking" id="planner" markup="no" lang="nl"}
{/exp:reinos_maps:map}
</main>
</div>
<p id="route-events"></p>
<script>
document.addEventListener('maps:route:loaded', function (event) {
document.getElementById('route-events').textContent = event.detail.route.distance + ', ' + event.detail.route.duration;
});
document.addEventListener('maps:route:error', function (event) {
document.getElementById('route-events').textContent = event.detail.error;
});
</script>
{exp:reinos_maps:html_footer}Build it in your own site
What this example needs in ExpressionEngine, step by step.
- Install Maps.
- Put the code in a template.
This example comes from the Maps docs: the preview runs exactly the code above.