• websites

SeatMap Multiple Selection


This sample allows to multiple select seats in a seatmap with one click: this is useful when an user wants to book adjacent seats without clicking multiple times; go here for the basic seatmap sample.


Additionally used AMP components must be imported in the header: amp-pan-zoom for making the seatmap zoomable and scrollable

<script async custom-element="amp-pan-zoom" src=""></script>

amp-bind for enabling seat selection

<script async custom-element="amp-bind" src=""></script>

amp-list for showing a list of seats

<script async custom-element="amp-list" src=""></script>

amp-mustache for rendering the amp-list content

<script async custom-template="amp-mustache" src=""></script>

amp-selector for selecting seats on the seatmap

<script async custom-element="amp-selector" src=""></script>

Seatmap state

Here we are using an amp-state called seatMultiSelection to keep all the useful information for the seat selection.

  • we load a list of neighbours seats from the server
  • selectedSeats contains a list of selected seat ids
  • numberOfSeats contains the number of seats we want automatically select
<amp-state id="seatMultiSelection" src="">
  <script type="application/json">
    "selectedSeats": [],
    "numberOfSeats": 3

Seatmap with multiple selection

Everytime a seat is selected, we automatically select the 2 seats on the right of it. In case the number of seats on the right of the selected one are less than 2, we only select the remaining on the line.

Seat map

<div class="seatmap-container">
 <h1>Seat map</h1>
 <amp-list layout="fill" src="" binding="refresh" items="." single-item noloading>
   <template type="amp-mustache">
     <amp-pan-zoom layout="fill" class="seatmap">
       <amp-selector on="select:AMP.setState({
         seatMultiSelection: {
           selectedSeats: event.selectedOptions.concat(
                         seatMultiSelection.neighbours[event.selectedOptions[0]].slice(0, seatMultiSelection.numberOfSeats-1))
         })" layout="fill">
         <div class="svg-container">
           <svg preserveAspectRatio="xMidYMin slice" viewBox="0 0 {{width}} {{height}}">
             <rect option="{{id}}" role="button" tabindex="0" class="seat {{unavailable}}" [class]="seatMultiSelection.selectedSeats.indexOf('{{id}}') != -1 ? 'selected seat {{unavailable}}' : 'seat {{unavailable}}'" x="{{x}}" y="{{y}}" width="{{width}}" height="{{height}}" rx="{{rx}}" ry="{{ry}}">
   <div placeholder>
     <svg class="disabled" viewBox="0 0  " preserveAspectRatio="xMidYMin slice">
Need further explanation?

If the explanations on this page don't cover all of your questions feel free to reach out to other AMP users to discuss your exact use case.

Go to Stack Overflow
An unexplained feature?

The AMP project strongly encourages your participation and contributions! We hope you'll become an ongoing participant in our open source community but we also welcome one-off contributions for the issues you're particularly passionate about.

Edit sample on GitHub